Example #1
0
static void
test_bt_cmd_application_info_for_incomplete_file (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtCmdApplication *app = bt_cmd_application_new (TRUE);
  gchar *tmp_file_name =
      g_build_filename (g_get_tmp_dir (), "broken2.xml.txt", NULL);

  GST_INFO ("-- act --");
  gboolean ret = bt_cmd_application_info (app,
      check_get_test_song_path ("broken2.xml"), tmp_file_name);

  GST_INFO ("-- assert --");
  fail_unless (ret == TRUE, NULL);
  fail_unless (check_file_contains_str (NULL, tmp_file_name,
          "song.song_info.name: \"broken 2\""), NULL);
  fail_unless (check_file_contains_str (NULL, tmp_file_name,
          "song.setup.number_of_missing_machines: 1"), NULL);
  fail_unless (check_file_contains_str (NULL, tmp_file_name,
          "song.wavetable.number_of_missing_waves: 2"), NULL);

  GST_INFO ("-- cleanup --");
  g_unlink (tmp_file_name);
  g_free (tmp_file_name);
  ck_g_object_final_unref (app);
  BT_TEST_END;
}
// load a song and show machine properties dialog
static void
test_bt_machine_preferences_dialog_create (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSong *song;
  BtSetup *setup;
  BtMachine *machine;
  GtkWidget *dialog;

  bt_edit_application_load_song (app, check_get_test_song_path ("melo3.xml"),
      NULL);
  g_object_get (app, "song", &song, NULL);
  g_object_get (song, "setup", &setup, NULL);
  machine = bt_setup_get_machine_by_id (setup, "beep1");

  GST_INFO ("-- act --");
  dialog = GTK_WIDGET (bt_machine_preferences_dialog_new (machine));

  GST_INFO ("-- assert --");
  fail_unless (dialog != NULL, NULL);
  gtk_widget_show_all (dialog);
  check_make_widget_screenshot (GTK_WIDGET (dialog), NULL);

  GST_INFO ("-- cleanup --");
  gtk_widget_destroy (dialog);
  g_object_unref (machine);
  g_object_unref (setup);
  g_object_unref (song);
  BT_TEST_END;
}
Example #3
0
static void
test_bt_cmd_application_play_two_files (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtCmdApplication *app = bt_cmd_application_new (TRUE);

  GST_INFO ("-- act --");
  bt_cmd_application_play (app, check_get_test_song_path ("test-simple1.xml"));
  gboolean ret = bt_cmd_application_play (app,
      check_get_test_song_path ("test-simple2.xml"));

  GST_INFO ("-- assert --");
  fail_unless (ret == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  ck_g_object_final_unref (app);
  BT_TEST_END;
}
Example #4
0
// load file into non empty song
static void
test_bt_song_io_native_load_twice (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSongIO *song_io =
      bt_song_io_from_file (check_get_test_song_path ("test-simple1.xml"),
      NULL);
  bt_song_io_load (song_io, song, NULL);
  ck_g_object_final_unref (song_io);
  song_io =
      bt_song_io_from_file (check_get_test_song_path ("test-simple2.xml"),
      NULL);

  /* act & assert */
  fail_unless (bt_song_io_load (song_io, song, NULL), NULL);

  GST_INFO ("-- cleanup --");
  ck_g_object_final_unref (song_io);
  BT_TEST_END;
}
Example #5
0
static void
test_launch_bt_dec (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  guint pix = _i >> 1;
  guint fix = _i & 1;
  gchar *str = g_strdup_printf (bt_dec_pipelines[pix],
      check_get_test_song_path (bt_dec_files[fix]));
  GstElement *pipeline = gst_parse_launch (str, NULL);
  GstMessageType message_types =
      GST_MESSAGE_NEW_CLOCK | GST_MESSAGE_STATE_CHANGED |
      GST_MESSAGE_STREAM_STATUS | GST_MESSAGE_ASYNC_DONE |
      GST_MESSAGE_STREAM_START | GST_MESSAGE_TAG;
  GstMessageType tmessage = GST_MESSAGE_EOS;

  GST_INFO ("-- act --");
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  GstStateChangeReturn ret = gst_element_get_state (pipeline, NULL, NULL,
      GST_CLOCK_TIME_NONE);

  GST_INFO ("-- assert --");
  fail_unless (ret == GST_STATE_CHANGE_SUCCESS,
      "Couldn't set pipeline to PLAYING: %s",
      gst_element_state_change_return_get_name (ret));

  GstBus *bus = gst_element_get_bus (pipeline);
  while (1) {
    GstMessageType rmessage = get_message_type (bus);
    if (rmessage == tmessage) {
      break;
    } else if (rmessage == GST_MESSAGE_UNKNOWN) {
      fail ("Unexpected timeout in gst_bus_poll, looking for %d", tmessage);
      break;
    } else if (rmessage & message_types) {
      continue;
    }
    fail ("Unexpected message received of type %d, '%s', looking for %d",
        rmessage, gst_message_type_get_name (rmessage), tmessage);
  }

  GST_INFO ("-- cleanup --");
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  g_free (str);
  BT_TEST_END;
}
Example #6
0
// load files with errors
static void
test_bt_song_io_native_bad_songs (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtSongIO *song_io =
      bt_song_io_from_file (check_get_test_song_path (bad_songs[_i]), NULL);

  GST_INFO ("-- act & assert --");
  GError *err = NULL;
  fail_if (bt_song_io_load (song_io, song, &err), NULL);
  fail_if (err == NULL, NULL);

  GST_INFO ("-- cleanup --");
  g_error_free (err);
  ck_g_object_final_unref (song_io);
  BT_TEST_END;
}
Example #7
0
static void
test_bt_cmd_application_play_incomplete_file (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtCmdApplication *app = bt_cmd_application_new (TRUE);

  GST_INFO ("-- act --");
  gboolean ret = bt_cmd_application_play (app,
      check_get_test_song_path ("broken2.xml"));

  GST_INFO ("-- assert --");
  // we should still attempt to play it
  fail_unless (ret == TRUE, NULL);

  GST_INFO ("-- cleanup --");
  ck_g_object_final_unref (app);
  BT_TEST_END;
}
Example #8
0
static void
test_bt_cmd_application_info (BT_TEST_ARGS)
{
  BT_TEST_START;
  GST_INFO ("-- arrange --");
  BtCmdApplication *app = bt_cmd_application_new (TRUE);
  gchar *tmp_file_name =
      g_build_filename (g_get_tmp_dir (), "test-simple1.xml.txt", NULL);

  GST_INFO ("-- act --");
  gboolean ret = bt_cmd_application_info (app,
      check_get_test_song_path ("test-simple1.xml"), tmp_file_name);

  GST_INFO ("-- assert --");
  fail_unless (ret == TRUE, NULL);
  fail_unless (check_file_contains_str (NULL, tmp_file_name,
          "song.song_info.name: \"test simple 1\""), NULL);

  GST_INFO ("-- cleanup --");
  g_unlink (tmp_file_name);
  g_free (tmp_file_name);
  ck_g_object_final_unref (app);
  BT_TEST_END;
}