| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <gtk/gtk.h> | |
| 6 | |
| 7 #include "chrome/browser/browser_window.h" | |
| 8 #include "chrome/browser/gtk/view_id_util.h" | |
| 9 #include "chrome/browser/tabs/tab_strip_model.h" | |
| 10 #include "chrome/browser/ui/browser.h" | |
| 11 #include "chrome/test/in_process_browser_test.h" | |
| 12 #include "chrome/test/ui_test_utils.h" | |
| 13 #include "net/test/test_server.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 const char kSimplePage[] = "404_is_enough_for_us.html"; | |
| 18 | |
| 19 void OnClicked(GtkWidget* widget, bool* clicked_bit) { | |
| 20 *clicked_bit = true; | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 class BookmarkBarGtkInteractiveUITest : public InProcessBrowserTest { | |
| 26 }; | |
| 27 | |
| 28 // Makes sure that when you switch back to an NTP with an active findbar, | |
| 29 // the findbar is above the floating bookmark bar. | |
| 30 IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, FindBarTest) { | |
| 31 ASSERT_TRUE(test_server()->Start()); | |
| 32 | |
| 33 // Create new tab; open findbar. | |
| 34 browser()->NewTab(); | |
| 35 browser()->Find(); | |
| 36 | |
| 37 // Create new tab with an arbitrary URL. | |
| 38 GURL url = test_server()->GetURL(kSimplePage); | |
| 39 browser()->AddSelectedTabWithURL(url, PageTransition::TYPED); | |
| 40 | |
| 41 // Switch back to the NTP with the active findbar. | |
| 42 browser()->SelectTabContentsAt(1, false); | |
| 43 | |
| 44 // Wait for the findbar to show. | |
| 45 MessageLoop::current()->RunAllPending(); | |
| 46 | |
| 47 // Set focus somewhere else, so that we can test clicking on the findbar | |
| 48 // works. | |
| 49 browser()->FocusLocationBar(); | |
| 50 ui_test_utils::ClickOnView(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | |
| 51 ui_test_utils::IsViewFocused(browser(), VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | |
| 52 } | |
| 53 | |
| 54 // Makes sure that you can click on the floating bookmark bar. | |
| 55 IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, ClickOnFloatingTest) { | |
| 56 ASSERT_TRUE(test_server()->Start()); | |
| 57 | |
| 58 GtkWidget* other_bookmarks = | |
| 59 ViewIDUtil::GetWidget(GTK_WIDGET(browser()->window()->GetNativeHandle()), | |
| 60 VIEW_ID_OTHER_BOOKMARKS); | |
| 61 bool has_been_clicked = false; | |
| 62 g_signal_connect(other_bookmarks, "clicked", | |
| 63 G_CALLBACK(OnClicked), &has_been_clicked); | |
| 64 | |
| 65 // Create new tab. | |
| 66 browser()->NewTab(); | |
| 67 | |
| 68 // Wait for the floating bar to appear. | |
| 69 MessageLoop::current()->RunAllPending(); | |
| 70 | |
| 71 // This is kind of a hack. Calling this just once doesn't seem to send a click | |
| 72 // event, but doing it twice works. | |
| 73 // http://crbug.com/35581 | |
| 74 ui_test_utils::ClickOnView(browser(), VIEW_ID_OTHER_BOOKMARKS); | |
| 75 ui_test_utils::ClickOnView(browser(), VIEW_ID_OTHER_BOOKMARKS); | |
| 76 | |
| 77 EXPECT_TRUE(has_been_clicked); | |
| 78 } | |
| OLD | NEW |