extern "C" void on_lock_info(GtkDasherControl *pDasherControl, gpointer pLockInfo, gpointer pUserData) { // TODO: signals are connected after the Dasher control is created, // which is too late to receive notification about intial training // etc. DasherLockInfo *pInfo = (DasherLockInfo *)pLockInfo; #ifndef WITH_MAEMO gtk_label_set_text(m_pLockMessage, pInfo->szMessage); gtk_progress_bar_set_fraction(m_pLockProgress, pInfo->iPercent / 100.0); if(pInfo->bLock) gtk_widget_show(GTK_WIDGET(m_pLockWindow)); else gtk_widget_hide(GTK_WIDGET(m_pLockWindow)); #else if(pInfo->bLock) { if(!m_pLockWindow) m_pLockWindow = hildon_banner_show_progress(NULL, NULL, pInfo->szMessage); hildon_banner_set_fraction(HILDON_BANNER(m_pLockWindow), pInfo->iPercent / 100.0); } else { if(m_pLockWindow) gtk_widget_destroy(GTK_WIDGET(m_pLockWindow)); m_pLockWindow = 0; } #endif // Keep the GTK interface responsive while(gtk_events_pending()) gtk_main_iteration(); }
END_TEST /* ----- Test case for show_progress -----*/ /** * Purpose: Check creation of new banner with progress bar with regular values. * Cases considered: * - Create new progress banner with standard progress bar and "" as text. * - Create new progress banner with NULL progress bar and TEST_STRING as text. */ START_TEST (test_show_progress_regular) { gchar * text=NULL; GtkProgressBar * progress_bar = NULL; HildonBanner * hildon_banner = NULL; progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new()); /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */ text = TEST_STRING; hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,text)); fail_if(!HILDON_IS_BANNER(hildon_banner), "hildon-banner: hildon_banner_show_progress failed creating banner."); hildon_banner_set_text(hildon_banner,text); hildon_banner_set_fraction(hildon_banner,0.5); gtk_widget_destroy(GTK_WIDGET(hildon_banner)); hildon_banner = NULL; /*Test 2: Create progress banner with "" as text and NULL progress_bar. */ text = ""; hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,NULL,text)); fail_if(!HILDON_IS_BANNER(hildon_banner), "hildon-banner: hildon_banner_show_progress failed creating banner."); hildon_banner_set_text(hildon_banner,text); hildon_banner_set_fraction(hildon_banner,0.2); gtk_widget_destroy(GTK_WIDGET(hildon_banner)); }
END_TEST /** * Purpose: Check creation of new banner with progress bar with invalid values * Cases considered: * - Create new progress banner with NULL text. * - Create new progress banner with NULL window. */ START_TEST (test_show_progress_invalid) { gchar * text=NULL; GtkProgressBar * progress_bar = NULL; HildonBanner * hildon_banner = NULL; progress_bar = GTK_PROGRESS_BAR(gtk_progress_bar_new()); /*Test 1: Create progress banner with TEST_STRING as text and basic progress_bar. */ text = TEST_STRING; hildon_banner = HILDON_BANNER(hildon_banner_show_progress(b_window,progress_bar,NULL)); /* NULL text avoid create correct banner. */ fail_if(HILDON_IS_BANNER(hildon_banner), "hildon-banner: hildon_banner_show_progress failed creating banner."); /*Test 2: Create progress banner with TEST_STRING as text, NULL progress_bar and NULL window */ text = TEST_STRING; hildon_banner = HILDON_BANNER(hildon_banner_show_progress(NULL,NULL,text)); fail_if(!HILDON_IS_BANNER(hildon_banner), "hildon-banner: hildon_banner_show_progress failed creating banner."); hildon_banner_set_text(hildon_banner,text); hildon_banner_set_fraction(hildon_banner,0.2); gtk_widget_destroy(GTK_WIDGET(hildon_banner)); }