From f8c0668e5ea513e4cb4e2ab26f12413f05da15fe Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 4 Sep 2016 09:38:47 -0400 Subject: [PATCH] gui/audio: Add an accessor function for the pause_after combo box Signed-off-by: Anna Schumaker --- gui/audio.c | 8 +++---- include/gui/audio.h | 6 +++++ share/ocarina/ocarina.ui | 4 ++-- tests/gui/audio.c | 49 ++++++++++++++-------------------------- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/gui/audio.c b/gui/audio.c index 4daff059..2d33157b 100644 --- a/gui/audio.c +++ b/gui/audio.c @@ -51,14 +51,12 @@ static void __audio_change_state(GstState state) static void __audio_config_pause(int n) { - GtkComboBox *combo = GTK_COMBO_BOX(gui_builder_widget("o_pause_after")); - gtk_combo_box_set_active(combo, n + 1); + gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), n + 1); } -void __audio_pause_changed(GtkComboBox *combo, gpointer data) +void __gui_audio_pause_changed(GtkComboBox *combo, gpointer data) { - int val = gtk_combo_box_get_active(combo) - 1; - audio_pause_after(val); + audio_pause_after(gtk_combo_box_get_active(combo) - 1); } void __audio_seek(GtkRange *range, GtkScrollType type, double value, gpointer data) diff --git a/include/gui/audio.h b/include/gui/audio.h index 5fcca3c3..6500c0d2 100644 --- a/include/gui/audio.h +++ b/include/gui/audio.h @@ -68,6 +68,12 @@ static inline GtkButton *gui_next_button(void) return GTK_BUTTON(gui_builder_widget("next_button")); } +/* Called to get the pause-fater combobox. */ +static inline GtkComboBoxText *gui_pause_after(void) +{ + return GTK_COMBO_BOX_TEXT(gui_builder_widget("pause_after")); +} + #ifdef CONFIG_TESTING void test_gui_audio_timeout(); #endif /* CONFIG_TESTING */ diff --git a/share/ocarina/ocarina.ui b/share/ocarina/ocarina.ui index ce850419..ffcee8de 100644 --- a/share/ocarina/ocarina.ui +++ b/share/ocarina/ocarina.ui @@ -556,7 +556,7 @@ audio-volume-medium - + True False end @@ -665,7 +665,7 @@ audio-volume-medium 98 tracks 99 tracks - + 4 diff --git a/tests/gui/audio.c b/tests/gui/audio.c index c18dd7ee..e7e0215b 100644 --- a/tests/gui/audio.c +++ b/tests/gui/audio.c @@ -20,17 +20,6 @@ struct core_init_data init_data = { .audio_ops = &audio_ops, }; -static inline gchar *test_get_pause_text() -{ - return gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(gui_builder_widget("o_pause_after"))); -} - -static inline void test_set_pause_after(unsigned int n) -{ - GtkComboBox *combo = GTK_COMBO_BOX(gui_builder_widget("o_pause_after")); - gtk_combo_box_set_active(combo, n + 1); -} - static void test_audio_seek(gint64 pos) { GstState state; @@ -49,6 +38,10 @@ static void test_audio_init() g_assert_cmpstr(gtk_label_get_text(gui_title_tag()), ==, " "); g_assert_cmpstr(gtk_label_get_text(gui_position()), ==, "0:00"); g_assert_cmpstr(gtk_label_get_text(gui_duration()), ==, "0:00"); + g_assert_cmpstr(gtk_combo_box_text_get_active_text(gui_pause_after()), + ==, "(disabled)"); + g_assert_cmpuint(gtk_combo_box_get_active( + GTK_COMBO_BOX(gui_pause_after())), ==, 0); g_assert_true( gtk_widget_is_visible(GTK_WIDGET(gui_play_button()))); g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_button()))); } @@ -94,6 +87,17 @@ static void test_audio_buttons() gtk_button_clicked(gui_prev_button()); g_assert(audio_cur_track() == track_get(0)); + + gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), 2); + audio_eos(); + g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING); + g_assert_cmpuint(gtk_combo_box_get_active( + GTK_COMBO_BOX(gui_pause_after())), ==, 1); + + audio_eos(); + g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED); + g_assert_cmpuint(gtk_combo_box_get_active( + GTK_COMBO_BOX(gui_pause_after())), ==, 0); } static void test_audio() @@ -101,34 +105,15 @@ static void test_audio() struct db_entry *dbe, *next; struct track *track; - g_assert_cmpstr_free(test_get_pause_text(), ==, "(disabled)"); - db_for_each(dbe, next, track_db_get()) { - if (TRACK(dbe)->tr_track == 1) { + if (TRACK(dbe)->tr_track == 4) { track = TRACK(dbe); break; } } audio_load(track); - g_assert_cmpuint(audio_cur_track()->tr_track, ==, track->tr_track); - - test_set_pause_after(0); - audio_eos(); - g_assert_cmpuint(audio_cur_track()->tr_track, ==, 3); - g_assert_cmpstr_free(test_get_pause_text(), ==, "(disabled)"); - - test_set_pause_after(1); - g_assert_cmpstr_free(test_get_pause_text(), ==, "next track"); - - audio_eos(); - g_assert_cmpuint(audio_cur_track()->tr_track, ==, 4); - g_assert_cmpstr_free(test_get_pause_text(), ==, "this track"); - - audio_eos(); - g_assert_cmpuint(audio_cur_track()->tr_track, ==, 5); - g_assert_cmpstr_free(test_get_pause_text(), ==, "(disabled)"); - + gtk_button_clicked(gui_pause_button()); test_audio_seek(71 * GST_SECOND); test_gui_audio_timeout(); g_assert_cmpuint(gtk_adjustment_get_upper(GTK_ADJUSTMENT(gui_builder_object("o_progress"))),