Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" | |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 13 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_command_controller.h" | 16 #include "chrome/browser/ui/browser_command_controller.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 18 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 19 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 void ToolbarViewTest::RunToolbarCycleFocusTest(Browser* browser) { | 41 void ToolbarViewTest::RunToolbarCycleFocusTest(Browser* browser) { |
| 41 gfx::NativeWindow window = browser->window()->GetNativeWindow(); | 42 gfx::NativeWindow window = browser->window()->GetNativeWindow(); |
| 42 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 43 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 43 views::FocusManager* focus_manager = widget->GetFocusManager(); | 44 views::FocusManager* focus_manager = widget->GetFocusManager(); |
| 44 CommandUpdater* updater = browser->command_controller()->command_updater(); | 45 CommandUpdater* updater = browser->command_controller()->command_updater(); |
| 45 | 46 |
| 46 // Send focus to the toolbar as if the user pressed Alt+Shift+T. | 47 // Send focus to the toolbar as if the user pressed Alt+Shift+T. |
| 47 updater->ExecuteCommand(IDC_FOCUS_TOOLBAR); | 48 updater->ExecuteCommand(IDC_FOCUS_TOOLBAR); |
| 49 base::RunLoop().RunUntilIdle(); | |
| 48 | 50 |
| 49 views::View* first_view = focus_manager->GetFocusedView(); | 51 views::View* first_view = focus_manager->GetFocusedView(); |
| 50 std::vector<int> ids; | 52 std::vector<int> ids; |
| 51 | 53 |
| 52 // Press Tab to cycle through all of the controls in the toolbar until | 54 // Press Tab to cycle through all of the controls in the toolbar until |
| 53 // we end up back where we started. | 55 // we end up back where we started. |
| 54 bool found_reload = false; | 56 bool found_reload = false; |
| 55 bool found_location_bar = false; | 57 bool found_location_bar = false; |
| 56 bool found_app_menu = false; | 58 bool found_app_menu = false; |
| 57 const views::View* view = NULL; | 59 const views::View* view = NULL; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 for (size_t i = 0; i < count - 1; i++) | 95 for (size_t i = 0; i < count - 1; i++) |
| 94 EXPECT_EQ(ids[i], reverse_ids[count - 2 - i]); | 96 EXPECT_EQ(ids[i], reverse_ids[count - 2 - i]); |
| 95 } | 97 } |
| 96 | 98 |
| 97 // The test is flaky on Win (http://crbug.com/152938) and crashes on CrOS under | 99 // The test is flaky on Win (http://crbug.com/152938) and crashes on CrOS under |
| 98 // AddressSanitizer (http://crbug.com/154657). | 100 // AddressSanitizer (http://crbug.com/154657). |
| 99 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, DISABLED_ToolbarCycleFocus) { | 101 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, DISABLED_ToolbarCycleFocus) { |
| 100 RunToolbarCycleFocusTest(browser()); | 102 RunToolbarCycleFocusTest(browser()); |
| 101 } | 103 } |
| 102 | 104 |
| 103 #if defined(OS_WIN) | 105 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, ToolbarCycleFocusWithBookmarkBar) { |
|
sky
2016/10/10 22:47:21
It seems as though this test relies on focus. If t
| |
| 104 // http://crbug.com/152938 Flaky on win. | |
| 105 #define MAYBE_ToolbarCycleFocusWithBookmarkBar \ | |
| 106 DISABLED_ToolbarCycleFocusWithBookmarkBar | |
| 107 #else | |
| 108 #define MAYBE_ToolbarCycleFocusWithBookmarkBar ToolbarCycleFocusWithBookmarkBar | |
| 109 #endif | |
| 110 IN_PROC_BROWSER_TEST_F(ToolbarViewTest, | |
| 111 MAYBE_ToolbarCycleFocusWithBookmarkBar) { | |
| 112 CommandUpdater* updater = browser()->command_controller()->command_updater(); | 106 CommandUpdater* updater = browser()->command_controller()->command_updater(); |
| 113 updater->ExecuteCommand(IDC_SHOW_BOOKMARK_BAR); | 107 updater->ExecuteCommand(IDC_SHOW_BOOKMARK_BAR); |
| 114 | 108 |
| 115 BookmarkModel* model = | 109 BookmarkModel* model = |
| 116 BookmarkModelFactory::GetForBrowserContext(browser()->profile()); | 110 BookmarkModelFactory::GetForBrowserContext(browser()->profile()); |
| 117 bookmarks::AddIfNotBookmarked( | 111 bookmarks::AddIfNotBookmarked( |
| 118 model, GURL("http://foo.com"), base::ASCIIToUTF16("Foo")); | 112 model, GURL("http://foo.com"), base::ASCIIToUTF16("Foo")); |
| 119 | 113 |
| 120 // We want to specifically test the case where the bookmark bar is | 114 // We want to specifically test the case where the bookmark bar is |
| 121 // already showing when a window opens, so create a second browser | 115 // already showing when a window opens, so create a second browser |
| 122 // window with the same profile. | 116 // window with the same profile. |
| 123 Browser* second_browser = CreateBrowser(browser()->profile()); | 117 Browser* second_browser = CreateBrowser(browser()->profile()); |
| 124 RunToolbarCycleFocusTest(second_browser); | 118 RunToolbarCycleFocusTest(second_browser); |
| 125 } | 119 } |
| 126 | 120 |
| 127 } // namespace | 121 } // namespace |
| OLD | NEW |