OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
| 7 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
7 #include "chrome/browser/ui/views/frame/browser_view.h" | 8 #include "chrome/browser/ui/views/frame/browser_view.h" |
8 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" | 9 #include "chrome/browser/ui/views/frame/test_with_browser_view.h" |
9 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" | 10 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" |
10 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 11 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
11 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 12 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
12 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" | 13 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h" |
13 #include "chrome/test/base/interactive_test_utils.h" | 14 #include "chrome/test/base/interactive_test_utils.h" |
14 #include "extensions/common/feature_switch.h" | 15 #include "extensions/common/feature_switch.h" |
15 | 16 |
16 // Borrowed from chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc, | 17 // Borrowed from chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 quit_closure); | 120 quit_closure); |
120 } | 121 } |
121 | 122 |
122 void ToolbarViewInteractiveUITest::SetUpCommandLine( | 123 void ToolbarViewInteractiveUITest::SetUpCommandLine( |
123 base::CommandLine* command_line) { | 124 base::CommandLine* command_line) { |
124 ExtensionBrowserTest::SetUpCommandLine(command_line); | 125 ExtensionBrowserTest::SetUpCommandLine(command_line); |
125 // We do this before the rest of the setup because it can affect how the views | 126 // We do this before the rest of the setup because it can affect how the views |
126 // are constructed. | 127 // are constructed. |
127 feature_override_.reset(new extensions::FeatureSwitch::ScopedOverride( | 128 feature_override_.reset(new extensions::FeatureSwitch::ScopedOverride( |
128 extensions::FeatureSwitch::extension_action_redesign(), true)); | 129 extensions::FeatureSwitch::extension_action_redesign(), true)); |
129 BrowserActionsContainer::disable_animations_during_testing_ = true; | 130 ToolbarActionsBar::disable_animations_for_testing_ = true; |
130 WrenchToolbarButton::g_open_wrench_immediately_for_testing = true; | 131 WrenchToolbarButton::g_open_wrench_immediately_for_testing = true; |
131 } | 132 } |
132 | 133 |
133 void ToolbarViewInteractiveUITest::SetUpOnMainThread() { | 134 void ToolbarViewInteractiveUITest::SetUpOnMainThread() { |
134 ExtensionBrowserTest::SetUpOnMainThread(); | 135 ExtensionBrowserTest::SetUpOnMainThread(); |
135 | 136 |
136 toolbar_view_ = BrowserView::GetBrowserViewForBrowser(browser())->toolbar(); | 137 toolbar_view_ = BrowserView::GetBrowserViewForBrowser(browser())->toolbar(); |
137 browser_actions_ = toolbar_view_->browser_actions(); | 138 browser_actions_ = toolbar_view_->browser_actions(); |
138 } | 139 } |
139 | 140 |
140 void ToolbarViewInteractiveUITest::TearDownOnMainThread() { | 141 void ToolbarViewInteractiveUITest::TearDownOnMainThread() { |
141 BrowserActionsContainer::disable_animations_during_testing_ = false; | 142 ToolbarActionsBar::disable_animations_for_testing_ = false; |
142 WrenchToolbarButton::g_open_wrench_immediately_for_testing = false; | 143 WrenchToolbarButton::g_open_wrench_immediately_for_testing = false; |
143 } | 144 } |
144 | 145 |
145 IN_PROC_BROWSER_TEST_F(ToolbarViewInteractiveUITest, | 146 IN_PROC_BROWSER_TEST_F(ToolbarViewInteractiveUITest, |
146 MAYBE(TestWrenchMenuOpensOnDrag)) { | 147 MAYBE(TestWrenchMenuOpensOnDrag)) { |
147 // Load an extension that has a browser action. | 148 // Load an extension that has a browser action. |
148 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") | 149 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("api_test") |
149 .AppendASCII("browser_action") | 150 .AppendASCII("browser_action") |
150 .AppendASCII("basics"))); | 151 .AppendASCII("basics"))); |
151 base::RunLoop().RunUntilIdle(); // Ensure the extension is fully loaded. | 152 base::RunLoop().RunUntilIdle(); // Ensure the extension is fully loaded. |
152 | 153 |
153 ASSERT_EQ(1u, browser_actions()->VisibleBrowserActions()); | 154 ASSERT_EQ(1u, browser_actions()->VisibleBrowserActions()); |
154 | 155 |
155 ToolbarActionView* view = browser_actions()->GetToolbarActionViewAt(0); | 156 ToolbarActionView* view = browser_actions()->GetToolbarActionViewAt(0); |
156 ASSERT_TRUE(view); | 157 ASSERT_TRUE(view); |
157 | 158 |
158 gfx::Point browser_action_view_loc = test::GetCenterInScreenCoordinates(view); | 159 gfx::Point browser_action_view_loc = test::GetCenterInScreenCoordinates(view); |
159 gfx::Point wrench_button_loc = | 160 gfx::Point wrench_button_loc = |
160 test::GetCenterInScreenCoordinates(toolbar_view()->app_menu()); | 161 test::GetCenterInScreenCoordinates(toolbar_view()->app_menu()); |
161 | 162 |
162 // Perform a drag and drop from the browser action view to the wrench button, | 163 // Perform a drag and drop from the browser action view to the wrench button, |
163 // which should open the wrench menu. | 164 // which should open the wrench menu. |
164 DoDragAndDrop(browser_action_view_loc, wrench_button_loc); | 165 DoDragAndDrop(browser_action_view_loc, wrench_button_loc); |
165 } | 166 } |
OLD | NEW |