OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 5 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
| 6 |
6 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
| 8 #include "base/memory/scoped_ptr.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/panels/panel.h" | 12 #include "chrome/browser/ui/panels/panel.h" |
12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 13 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
13 #include "chrome/browser/ui/panels/panel_browser_view.h" | 14 #include "chrome/browser/ui/panels/panel_browser_view.h" |
14 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
15 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" | 16 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" |
16 #include "chrome/browser/web_applications/web_app.h" | 17 #include "chrome/browser/web_applications/web_app.h" |
17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/base/animation/slide_animation.h" | 23 #include "ui/base/animation/slide_animation.h" |
24 #include "views/controls/button/image_button.h" | 24 #include "views/controls/button/image_button.h" |
25 #include "views/controls/button/menu_button.h" | 25 #include "views/controls/button/menu_button.h" |
26 #include "views/controls/image_view.h" | 26 #include "views/controls/image_view.h" |
27 #include "views/controls/label.h" | 27 #include "views/controls/label.h" |
28 #include "views/controls/link.h" | 28 #include "views/controls/link.h" |
29 #include "views/controls/textfield/textfield.h" | 29 #include "views/controls/textfield/textfield.h" |
30 | 30 |
31 class PanelBrowserViewTest : public InProcessBrowserTest { | 31 class PanelBrowserViewTest : public BasePanelBrowserTest { |
32 public: | 32 public: |
33 PanelBrowserViewTest() : InProcessBrowserTest() { } | 33 PanelBrowserViewTest() : BasePanelBrowserTest() { } |
34 | |
35 virtual void SetUpCommandLine(CommandLine* command_line) { | |
36 command_line->AppendSwitch(switches::kEnablePanels); | |
37 } | |
38 | 34 |
39 protected: | 35 protected: |
40 struct MenuItem { | 36 struct MenuItem { |
41 int id; | 37 int id; |
42 bool enabled; | 38 bool enabled; |
43 }; | 39 }; |
44 | 40 |
45 class MockMouseWatcher : public PanelBrowserFrameView::MouseWatcher { | 41 class MockMouseWatcher : public PanelBrowserFrameView::MouseWatcher { |
46 public: | 42 public: |
47 explicit MockMouseWatcher(PanelBrowserFrameView* view) | 43 explicit MockMouseWatcher(PanelBrowserFrameView* view) |
(...skipping 16 matching lines...) Expand all Loading... |
64 GdkEvent event; | 60 GdkEvent event; |
65 event.type = GDK_MOTION_NOTIFY; | 61 event.type = GDK_MOTION_NOTIFY; |
66 DidProcessEvent(&event); | 62 DidProcessEvent(&event); |
67 #endif | 63 #endif |
68 } | 64 } |
69 | 65 |
70 private: | 66 private: |
71 bool is_cursor_in_view_; | 67 bool is_cursor_in_view_; |
72 }; | 68 }; |
73 | 69 |
74 enum ShowFlag { SHOW_AS_ACTIVE, SHOW_AS_INACTIVE }; | |
75 | |
76 PanelBrowserView* CreatePanelBrowserView(const std::string& panel_name, | 70 PanelBrowserView* CreatePanelBrowserView(const std::string& panel_name, |
77 ShowFlag show_flag) { | 71 ShowFlag show_flag) { |
78 Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, | 72 Panel* panel = CreatePanel(panel_name, gfx::Rect(), show_flag); |
79 panel_name, | |
80 gfx::Rect(), | |
81 browser()->profile()); | |
82 Panel* panel = static_cast<Panel*>(panel_browser->window()); | |
83 if (show_flag == SHOW_AS_ACTIVE) | |
84 panel->Show(); | |
85 else | |
86 panel->ShowInactive(); | |
87 return static_cast<PanelBrowserView*>(panel->native_panel()); | 73 return static_cast<PanelBrowserView*>(panel->native_panel()); |
88 } | 74 } |
89 | 75 |
90 void WaitTillBoundsAnimationFinished(PanelBrowserView* browser_view) { | 76 void WaitTillBoundsAnimationFinished(PanelBrowserView* browser_view) { |
91 // The timer for the animation will only kick in as async task. | 77 // The timer for the animation will only kick in as async task. |
92 while (browser_view->bounds_animator_->is_animating()) { | 78 while (browser_view->bounds_animator_->is_animating()) { |
93 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 79 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
94 MessageLoop::current()->RunAllPending(); | 80 MessageLoop::current()->RunAllPending(); |
95 } | 81 } |
96 } | 82 } |
(...skipping 15 matching lines...) Expand all Loading... |
112 settings_menu_contents->IsEnabledAt(i)); | 98 settings_menu_contents->IsEnabledAt(i)); |
113 } | 99 } |
114 } | 100 } |
115 } | 101 } |
116 | 102 |
117 void TestCreateSettingsMenuForExtension(const FilePath::StringType& path, | 103 void TestCreateSettingsMenuForExtension(const FilePath::StringType& path, |
118 Extension::Location location, | 104 Extension::Location location, |
119 const std::string& homepage_url, | 105 const std::string& homepage_url, |
120 const std::string& options_page) { | 106 const std::string& options_page) { |
121 // Creates a testing extension. | 107 // Creates a testing extension. |
122 #if defined(OS_WIN) | 108 DictionaryValue extra_value; |
123 FilePath full_path(FILE_PATH_LITERAL("c:\\")); | |
124 #else | |
125 FilePath full_path(FILE_PATH_LITERAL("/")); | |
126 #endif | |
127 full_path = full_path.Append(path); | |
128 DictionaryValue input_value; | |
129 input_value.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | |
130 input_value.SetString(extension_manifest_keys::kName, "Sample Extension"); | |
131 if (!homepage_url.empty()) { | 109 if (!homepage_url.empty()) { |
132 input_value.SetString(extension_manifest_keys::kHomepageURL, | 110 extra_value.SetString(extension_manifest_keys::kHomepageURL, |
133 homepage_url); | 111 homepage_url); |
134 } | 112 } |
135 if (!options_page.empty()) { | 113 if (!options_page.empty()) { |
136 input_value.SetString(extension_manifest_keys::kOptionsPage, | 114 extra_value.SetString(extension_manifest_keys::kOptionsPage, |
137 options_page); | 115 options_page); |
138 } | 116 } |
139 std::string error; | 117 scoped_refptr<Extension> extension = CreateExtension( |
140 scoped_refptr<Extension> extension = Extension::Create( | 118 path, location, extra_value); |
141 full_path, location, input_value, Extension::STRICT_ERROR_CHECKS, | |
142 &error); | |
143 ASSERT_TRUE(extension.get()); | |
144 EXPECT_STREQ("", error.c_str()); | |
145 browser()->GetProfile()->GetExtensionService()->OnLoadSingleExtension( | |
146 extension.get(), false); | |
147 | 119 |
148 // Creates a panel with the app name that comes from the extension ID. | 120 // Creates a panel with the app name that comes from the extension ID. |
149 PanelBrowserView* browser_view = CreatePanelBrowserView( | 121 PanelBrowserView* browser_view = CreatePanelBrowserView( |
150 web_app::GenerateApplicationNameFromExtensionId(extension->id()), | 122 web_app::GenerateApplicationNameFromExtensionId(extension->id()), |
151 SHOW_AS_ACTIVE); | 123 SHOW_AS_ACTIVE); |
152 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 124 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
153 | 125 |
154 frame_view->EnsureSettingsMenuCreated(); | 126 frame_view->EnsureSettingsMenuCreated(); |
155 | 127 |
156 // Validates the settings menu items. | 128 // Validates the settings menu items. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, | 165 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, |
194 frame_view2->paint_state_); | 166 frame_view2->paint_state_); |
195 | 167 |
196 browser_view1->panel()->Close(); | 168 browser_view1->panel()->Close(); |
197 browser_view2->panel()->Close(); | 169 browser_view2->panel()->Close(); |
198 } | 170 } |
199 | 171 |
200 // We put all the testing logic in this class instead of the test so that | 172 // We put all the testing logic in this class instead of the test so that |
201 // we do not need to declare each new test as a friend of PanelBrowserView | 173 // we do not need to declare each new test as a friend of PanelBrowserView |
202 // for the purpose of accessing its private members. | 174 // for the purpose of accessing its private members. |
203 void TestMinimizeAndRestore() { | 175 void TestMinimizeAndRestore(bool enable_auto_hide) { |
| 176 PanelManager* panel_manager = PanelManager::GetInstance(); |
| 177 |
| 178 // Setup the mock bottom bar. |
| 179 mock_auto_hide_bottom_bar()->enable_auto_hide(enable_auto_hide); |
| 180 int expected_bottom_on_unminimized = |
| 181 testing_work_area().height() - mock_auto_hide_bottom_bar()->GetHeight(); |
| 182 int expected_bottom_on_minimized = testing_work_area().height(); |
| 183 |
| 184 // Create and test one panel first. |
204 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1", | 185 PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1", |
205 SHOW_AS_ACTIVE); | 186 SHOW_AS_ACTIVE); |
206 Panel* panel1 = browser_view1->panel_.get(); | 187 Panel* panel1 = browser_view1->panel_.get(); |
207 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); | 188 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); |
208 | 189 |
209 // Test minimizing/restoring an individual panel. | 190 // Test minimizing/restoring an individual panel. |
210 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); | 191 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
211 int initial_height = panel1->GetBounds().height(); | 192 int initial_height = panel1->GetBounds().height(); |
212 int titlebar_height = | 193 int titlebar_height = |
213 browser_view1->GetFrameView()->NonClientTopBorderHeight(); | 194 browser_view1->GetFrameView()->NonClientTopBorderHeight(); |
214 | 195 |
215 panel1->SetExpansionState(Panel::MINIMIZED); | 196 panel1->SetExpansionState(Panel::MINIMIZED); |
216 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 197 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
217 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); | 198 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
218 EXPECT_GT(panel1->GetBounds().height(), 0); | 199 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 200 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
219 EXPECT_TRUE(IsMouseWatcherStarted()); | 201 EXPECT_TRUE(IsMouseWatcherStarted()); |
220 EXPECT_FALSE(panel1->IsActive()); | 202 EXPECT_FALSE(panel1->IsActive()); |
221 WaitTillBoundsAnimationFinished(browser_view1); | 203 WaitTillBoundsAnimationFinished(browser_view1); |
222 | 204 |
223 panel1->SetExpansionState(Panel::TITLE_ONLY); | 205 panel1->SetExpansionState(Panel::TITLE_ONLY); |
224 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 206 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
225 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); | 207 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 208 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
226 WaitTillBoundsAnimationFinished(browser_view1); | 209 WaitTillBoundsAnimationFinished(browser_view1); |
227 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); | 210 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); |
228 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); | 211 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); |
229 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); | 212 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); |
230 | 213 |
231 panel1->SetExpansionState(Panel::EXPANDED); | 214 panel1->SetExpansionState(Panel::EXPANDED); |
232 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); | 215 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
233 EXPECT_EQ(initial_height, panel1->GetBounds().height()); | 216 EXPECT_EQ(initial_height, panel1->GetBounds().height()); |
| 217 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
234 WaitTillBoundsAnimationFinished(browser_view1); | 218 WaitTillBoundsAnimationFinished(browser_view1); |
235 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); | 219 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); |
236 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); | 220 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); |
237 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); | 221 EXPECT_TRUE(frame_view1->title_label_->IsVisible()); |
238 | 222 |
239 panel1->SetExpansionState(Panel::TITLE_ONLY); | 223 panel1->SetExpansionState(Panel::TITLE_ONLY); |
240 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 224 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
241 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); | 225 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
| 226 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
242 | 227 |
243 panel1->SetExpansionState(Panel::MINIMIZED); | 228 panel1->SetExpansionState(Panel::MINIMIZED); |
244 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 229 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
245 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); | 230 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
246 EXPECT_GT(panel1->GetBounds().height(), 0); | 231 EXPECT_GT(panel1->GetBounds().height(), 0); |
| 232 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
247 | 233 |
248 // Create 2 more panels for more testing. | 234 // Create 2 more panels for more testing. |
249 PanelBrowserView* browser_view2 = CreatePanelBrowserView("PanelTest2", | 235 PanelBrowserView* browser_view2 = CreatePanelBrowserView("PanelTest2", |
250 SHOW_AS_ACTIVE); | 236 SHOW_AS_ACTIVE); |
251 Panel* panel2 = browser_view2->panel_.get(); | 237 Panel* panel2 = browser_view2->panel_.get(); |
252 | 238 |
253 PanelBrowserView* browser_view3 = CreatePanelBrowserView("PanelTest3", | 239 PanelBrowserView* browser_view3 = CreatePanelBrowserView("PanelTest3", |
254 SHOW_AS_ACTIVE); | 240 SHOW_AS_ACTIVE); |
255 Panel* panel3 = browser_view3->panel_.get(); | 241 Panel* panel3 = browser_view3->panel_.get(); |
256 | 242 |
257 // Test bringing up or down the title-bar of all minimized panels. | 243 // Test bringing up or down the title-bar of all minimized panels. |
258 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 244 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
259 panel3->SetExpansionState(Panel::MINIMIZED); | 245 panel3->SetExpansionState(Panel::MINIMIZED); |
260 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); | 246 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
261 | 247 |
262 PanelManager* panel_manager = PanelManager::GetInstance(); | 248 mock_auto_hide_bottom_bar()->SetVisibility(AutoHideBottomBar::VISIBLE); |
263 | 249 panel_manager->BringUpOrDownTitlebars(true); |
264 panel_manager->BringUpOrDownTitlebarForAllMinimizedPanels(true); | 250 MessageLoop::current()->RunAllPending(); |
265 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 251 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
266 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 252 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
267 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); | 253 EXPECT_EQ(Panel::TITLE_ONLY, panel3->expansion_state()); |
268 | 254 |
269 panel_manager->BringUpOrDownTitlebarForAllMinimizedPanels(false); | 255 mock_auto_hide_bottom_bar()->SetVisibility(AutoHideBottomBar::HIDDEN); |
| 256 panel_manager->BringUpOrDownTitlebars(false); |
| 257 MessageLoop::current()->RunAllPending(); |
270 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 258 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
271 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); | 259 EXPECT_EQ(Panel::EXPANDED, panel2->expansion_state()); |
272 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); | 260 EXPECT_EQ(Panel::MINIMIZED, panel3->expansion_state()); |
273 | 261 |
274 // Test if it is OK to bring up title-bar given the mouse position. | 262 // Test if it is OK to bring up title-bar given the mouse position. |
275 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 263 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
276 panel1->GetBounds().x(), panel1->GetBounds().y())); | 264 panel1->GetBounds().x(), panel1->GetBounds().y())); |
277 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 265 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
278 panel2->GetBounds().x(), panel2->GetBounds().y())); | 266 panel2->GetBounds().x(), panel2->GetBounds().y())); |
279 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 267 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
280 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() - 1)); | 268 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() - 1)); |
281 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 269 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
282 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() + 10)); | 270 panel3->GetBounds().right() - 1, panel3->GetBounds().bottom() + 10)); |
283 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 271 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
284 0, 0)); | 272 0, 0)); |
285 | 273 |
286 // Test that the panel in title-only state should not be minimized | 274 // Test that the panel in title-only state should not be minimized |
287 // regardless of the current mouse position when the panel is being dragged. | 275 // regardless of the current mouse position when the panel is being dragged. |
288 panel1->SetExpansionState(Panel::TITLE_ONLY); | 276 panel1->SetExpansionState(Panel::TITLE_ONLY); |
289 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 277 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
290 0, 0)); | 278 0, 0)); |
291 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); | 279 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); |
292 browser_view1->OnTitlebarMouseDragged( | 280 browser_view1->OnTitlebarMouseDragged( |
293 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); | 281 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); |
294 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebarForAllMinimizedPanels( | 282 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
295 0, 0)); | 283 0, 0)); |
296 browser_view1->OnTitlebarMouseReleased(); | 284 browser_view1->OnTitlebarMouseReleased(); |
297 | 285 |
298 panel1->Close(); | 286 panel1->Close(); |
299 EXPECT_TRUE(IsMouseWatcherStarted()); | 287 EXPECT_TRUE(IsMouseWatcherStarted()); |
300 panel2->Close(); | 288 panel2->Close(); |
301 EXPECT_TRUE(IsMouseWatcherStarted()); | 289 EXPECT_TRUE(IsMouseWatcherStarted()); |
302 panel3->Close(); | 290 panel3->Close(); |
303 EXPECT_FALSE(IsMouseWatcherStarted()); | 291 EXPECT_FALSE(IsMouseWatcherStarted()); |
304 } | 292 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); | 326 EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state()); |
339 browser_view->DrawAttention(); | 327 browser_view->DrawAttention(); |
340 EXPECT_TRUE(browser_view->IsDrawingAttention()); | 328 EXPECT_TRUE(browser_view->IsDrawingAttention()); |
341 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 329 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
342 MessageLoop::current()->RunAllPending(); | 330 MessageLoop::current()->RunAllPending(); |
343 EXPECT_EQ(attention_color, frame_view->title_label_->GetColor()); | 331 EXPECT_EQ(attention_color, frame_view->title_label_->GetColor()); |
344 | 332 |
345 // Test that we cannot bring up other minimized panel if the mouse is over | 333 // Test that we cannot bring up other minimized panel if the mouse is over |
346 // the panel that draws attension. | 334 // the panel that draws attension. |
347 EXPECT_FALSE(PanelManager::GetInstance()-> | 335 EXPECT_FALSE(PanelManager::GetInstance()-> |
348 ShouldBringUpTitlebarForAllMinimizedPanels( | 336 ShouldBringUpTitlebars(panel->GetBounds().x(), panel->GetBounds().y())); |
349 panel->GetBounds().x(), panel->GetBounds().y())); | |
350 | 337 |
351 // Test that we cannot bring down the panel that is drawing the attention. | 338 // Test that we cannot bring down the panel that is drawing the attention. |
352 PanelManager::GetInstance()->BringUpOrDownTitlebarForAllMinimizedPanels( | 339 PanelManager::GetInstance()->BringUpOrDownTitlebars(false); |
353 false); | |
354 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); | 340 EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state()); |
355 | 341 |
356 // Test that the attention is cleared. | 342 // Test that the attention is cleared. |
357 browser_view->StopDrawingAttention(); | 343 browser_view->StopDrawingAttention(); |
358 EXPECT_FALSE(browser_view->IsDrawingAttention()); | 344 EXPECT_FALSE(browser_view->IsDrawingAttention()); |
359 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); | 345 EXPECT_EQ(Panel::EXPANDED, panel->expansion_state()); |
360 MessageLoop::current()->RunAllPending(); | 346 MessageLoop::current()->RunAllPending(); |
361 EXPECT_NE(attention_color, frame_view->title_label_->GetColor()); | 347 EXPECT_NE(attention_color, frame_view->title_label_->GetColor()); |
362 | 348 |
363 panel->Close(); | 349 panel->Close(); |
364 } | 350 } |
| 351 |
| 352 void TestChangeAutoHideTaskBarHeight() { |
| 353 mock_auto_hide_bottom_bar()->enable_auto_hide(true); |
| 354 int test_work_area_bottom = testing_work_area().height(); |
| 355 int mock_bar_height = mock_auto_hide_bottom_bar()->GetHeight(); |
| 356 |
| 357 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest", |
| 358 SHOW_AS_ACTIVE); |
| 359 Panel* panel = browser_view->panel_.get(); |
| 360 EXPECT_EQ(test_work_area_bottom - mock_bar_height, |
| 361 panel->GetBounds().bottom()); |
| 362 |
| 363 int new_mock_bar_height = mock_bar_height + 10; |
| 364 mock_auto_hide_bottom_bar()->SetHeight(new_mock_bar_height); |
| 365 MessageLoop::current()->RunAllPending(); |
| 366 EXPECT_EQ(test_work_area_bottom - new_mock_bar_height, |
| 367 panel->GetBounds().bottom()); |
| 368 |
| 369 new_mock_bar_height = 0; |
| 370 mock_auto_hide_bottom_bar()->SetHeight(new_mock_bar_height); |
| 371 MessageLoop::current()->RunAllPending(); |
| 372 EXPECT_EQ(test_work_area_bottom - new_mock_bar_height, |
| 373 panel->GetBounds().bottom()); |
| 374 |
| 375 new_mock_bar_height = mock_bar_height - 10; |
| 376 mock_auto_hide_bottom_bar()->SetHeight(new_mock_bar_height); |
| 377 MessageLoop::current()->RunAllPending(); |
| 378 EXPECT_EQ(test_work_area_bottom - new_mock_bar_height, |
| 379 panel->GetBounds().bottom()); |
| 380 |
| 381 panel->Close(); |
| 382 } |
365 }; | 383 }; |
366 | 384 |
367 // Panel is not supported for Linux view yet. | 385 // Panel is not supported for Linux view yet. |
368 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) | 386 #if !defined(OS_LINUX) || !defined(TOOLKIT_VIEWS) |
369 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { | 387 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreatePanel) { |
370 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest", | 388 PanelBrowserView* browser_view = CreatePanelBrowserView("PanelTest", |
371 SHOW_AS_ACTIVE); | 389 SHOW_AS_ACTIVE); |
372 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 390 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
373 | 391 |
374 // The bounds animation should not be triggered when the panel is up for the | 392 // The bounds animation should not be triggered when the panel is up for the |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 505 |
488 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { | 506 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, CreateSettingsMenu) { |
489 TestCreateSettingsMenuForExtension( | 507 TestCreateSettingsMenuForExtension( |
490 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, | 508 FILE_PATH_LITERAL("extension1"), Extension::EXTERNAL_POLICY_DOWNLOAD, |
491 "", ""); | 509 "", ""); |
492 TestCreateSettingsMenuForExtension( | 510 TestCreateSettingsMenuForExtension( |
493 FILE_PATH_LITERAL("extension2"), Extension::INVALID, | 511 FILE_PATH_LITERAL("extension2"), Extension::INVALID, |
494 "http://home", "options.html"); | 512 "http://home", "options.html"); |
495 } | 513 } |
496 | 514 |
497 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, MinimizeAndRestore) { | 515 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
498 TestMinimizeAndRestore(); | 516 MinimizeAndRestoreOnNormalTaskBar) { |
| 517 // Test that the taskbar is always visible. |
| 518 TestMinimizeAndRestore(false); |
| 519 } |
| 520 |
| 521 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, |
| 522 MinimizeAndRestoreOnAutoHideTaskBar) { |
| 523 // Test that the taskbar is in auto-hide mode. |
| 524 TestMinimizeAndRestore(true); |
499 } | 525 } |
500 | 526 |
501 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { | 527 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DrawAttention) { |
502 TestDrawAttention(); | 528 TestDrawAttention(); |
503 } | 529 } |
| 530 |
| 531 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarHeight) { |
| 532 TestChangeAutoHideTaskBarHeight(); |
| 533 } |
504 #endif | 534 #endif |
OLD | NEW |