Exemplo n.º 1
0
static void
test_bt_change_log_nested_groups (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  BtTestChangeLogger *tcl = bt_test_change_logger_new ();

  // make 1 change group
  bt_change_log_start_group (cl);
  make_change (cl, tcl, "new_data 2", "new_data 0");
  make_change (cl, tcl, "inc_data 0", "dec_data 0");
  bt_change_log_start_group (cl);
  make_change (cl, tcl, "inc_data 1", "dec_data 1");
  bt_change_log_end_group (cl);
  bt_change_log_end_group (cl);

  // undo & verify
  bt_change_log_undo (cl);
  fail_unless (tcl->data == NULL, NULL);
  ck_assert_int_eq (tcl->data_size, 0);

  // redo & verify
  bt_change_log_redo (cl);
  fail_unless (tcl->data != NULL, NULL);
  ck_assert_int_eq (tcl->data_size, 2);
  ck_assert_int_eq (tcl->data[0], 1);
  ck_assert_int_eq (tcl->data[1], 1);

  GST_INFO ("-- cleanup --");
  g_object_unref (tcl);
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 2
0
static void
test_bt_change_log_recover (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  gchar *log_name = g_build_filename (g_get_tmp_dir (), "bt-crash.log", NULL);
  gchar content[] =
      PACKAGE " edit journal : " PACKAGE_VERSION "\n"
      "\n"
      "BtMainPageMachines::add_machine 0,\"synth\",\"simsyn\"\n"
      "BtMainPageMachines::set_machine_property \"synth\",\"ypos\",\"-0.3\"\n"
      "BtMainPageMachines::set_machine_property \"synth\",\"xpos\",\"-0.4\"\n";
  g_file_set_contents (log_name, content, strlen (content), NULL);

  GST_INFO ("-- act --");
  gboolean res = bt_change_log_recover (cl, log_name);

  GST_INFO ("-- assert --");
  fail_unless (res, NULL);

  GST_INFO ("-- cleanup --");
  flush_main_loop ();
  g_unlink (log_name);
  g_free (log_name);
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 3
0
// test double undo/redo actions
static void
test_bt_change_log_two_changes (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  BtTestChangeLogger *tcl = bt_test_change_logger_new ();

  /* act (make 2 changes) */
  make_change (cl, tcl, "set_val 5", "set_val 0");
  make_change (cl, tcl, "set_val 10", "set_val 5");

  // undo & verify
  bt_change_log_undo (cl);
  ck_assert_int_eq (tcl->val, 5);

  bt_change_log_undo (cl);
  ck_assert_int_eq (tcl->val, 0);

  // redo & verify
  bt_change_log_redo (cl);
  ck_assert_int_eq (tcl->val, 5);

  bt_change_log_redo (cl);
  ck_assert_int_eq (tcl->val, 10);

  GST_INFO ("-- cleanup --");
  g_object_unref (tcl);
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 4
0
static GObject *
bt_edit_application_constructor (GType type, guint n_construct_params,
    GObjectConstructParam * construct_params)
{
  GObject *object;

  if (G_UNLIKELY (!singleton)) {
    object =
        G_OBJECT_CLASS (bt_edit_application_parent_class)->constructor (type,
        n_construct_params, construct_params);
    singleton = BT_EDIT_APPLICATION (object);
    g_object_add_weak_pointer (object, (gpointer *) (gpointer) & singleton);

    //GST_DEBUG("<<<");
    GST_INFO ("new edit app instantiated");
    // create or ref the shared ui resources
    singleton->priv->ui_resources = bt_ui_resources_new ();

    // create the interaction controller registry
    singleton->priv->ic_registry = btic_registry_new ();
    btic_registry_start_discovery ();

    // create the playback controllers (we need to create them all as they watch
    // the settings them self)
    singleton->priv->pbc_socket = bt_playback_controller_socket_new ();
    singleton->priv->pbc_ic = bt_playback_controller_ic_new ();

    // create the editor change log
    singleton->priv->change_log = bt_change_log_new ();
    g_signal_connect (singleton->priv->change_log, "notify::can-undo",
        G_CALLBACK (on_changelog_can_undo_changed), (gpointer) singleton);
    // create the audio_session
    singleton->priv->audio_session = bt_audio_session_new ();

    // create main window
    GST_INFO ("new edit app created, app: %" G_OBJECT_REF_COUNT_FMT,
        G_OBJECT_LOG_REF_COUNT (singleton));
    singleton->priv->main_window = bt_main_window_new ();
    gtk_widget_show_all (GTK_WIDGET (singleton->priv->main_window));
    GST_INFO ("new main_window shown");

    // warning: dereferencing type-punned pointer will break strict-aliasing rules
    g_object_add_weak_pointer (G_OBJECT (singleton->priv->main_window),
        (gpointer *) (gpointer) & singleton->priv->main_window);
    GST_INFO ("new edit app created, app: %" G_OBJECT_REF_COUNT_FMT,
        G_OBJECT_LOG_REF_COUNT (singleton));
    //GST_DEBUG(">>>");
  } else {
    object = g_object_ref (singleton);
  }
  return object;
}
Exemplo n.º 5
0
// test lifecycle/refcounts
static void
test_bt_change_log_create_and_destroy (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");

  GST_INFO ("-- act --");
  BtChangeLog *cl = bt_change_log_new ();

  GST_INFO ("-- assert --");
  fail_unless (cl != NULL, NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 6
0
static void
test_bt_change_log_initial_undo_redo_state (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  gboolean can_undo, can_redo;

  GST_INFO ("-- act --");
  g_object_get (cl, "can-undo", &can_undo, "can-redo", &can_redo, NULL);

  GST_INFO ("-- assert --");
  fail_unless (!can_undo, NULL);
  fail_unless (!can_redo, NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 7
0
// test single undo/redo actions
static void
test_bt_change_log_single_change_after_undo (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  BtTestChangeLogger *tcl = bt_test_change_logger_new ();

  GST_INFO ("-- act --");
  make_change (cl, tcl, "set_val 5", "set_val 0");
  bt_change_log_undo (cl);

  GST_INFO ("-- assert --");
  ck_assert_int_eq (tcl->val, 0);

  GST_INFO ("-- cleanup --");
  g_object_unref (tcl);
  g_object_unref (cl);
  BT_TEST_END;
}
Exemplo n.º 8
0
static void
on_recover_clicked (GtkButton * button, gpointer user_data)
{
  BtCrashRecoverDialog *self = BT_CRASH_RECOVER_DIALOG (user_data);
  gchar *log_name = get_selected (self);
  gboolean res = FALSE;
  BtMainWindow *main_window;

  if (log_name) {
    BtChangeLog *change_log = bt_change_log_new ();

    GST_INFO ("recovering: %s", log_name);
    if (bt_change_log_recover (change_log, log_name)) {
      remove_selected (self);
      res = TRUE;
    }
    g_free (log_name);
    g_object_try_unref (change_log);
  }
  g_object_get (self->priv->app, "main-window", &main_window, NULL);
  /* close the recovery dialog */
  gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE);
  if (res) {
    /* the song recovery has been finished */
    bt_dialog_message (main_window, _("Recovery finished"),
        _("The selected song has been recovered successful."),
        _("Please check the song and save it if everything is alright.")
        );
  } else {
    /* FIXME(ensonic): the log is still there
     * - this dialog should be a warning
     * - ev. we want to suggest to ask for support
     */
    /* one or more steps in the recovery did not apply */
    bt_dialog_message (main_window, _("Recovery failed"),
        _("Sorry, the selected song could not be fully recovered."),
        _("Please check the song and save it if still looks good.")
        );
  }
  g_object_unref (main_window);
}
Exemplo n.º 9
0
static void
test_bt_change_log_undo_redo_state_after_single_change (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtChangeLog *cl = bt_change_log_new ();
  BtTestChangeLogger *tcl = bt_test_change_logger_new ();
  gboolean can_undo, can_redo;

  GST_INFO ("-- act --");
  make_change (cl, tcl, "set_val 5", "set_val 0");
  g_object_get (cl, "can-undo", &can_undo, "can-redo", &can_redo, NULL);

  GST_INFO ("-- assert --");
  fail_unless (can_undo, NULL);
  fail_unless (!can_redo, NULL);

  GST_INFO ("-- cleanup --");
  g_object_unref (tcl);
  g_object_unref (cl);
  BT_TEST_END;
}