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/i18n/time_formatting.h" | 5 #include "base/i18n/time_formatting.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/panels/base_panel_browser_test.h" | 10 #include "chrome/browser/ui/panels/base_panel_browser_test.h" |
11 #include "chrome/browser/ui/panels/panel.h" | 11 #include "chrome/browser/ui/panels/panel.h" |
12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" | 12 #include "chrome/browser/ui/panels/panel_browser_frame_view.h" |
13 #include "chrome/browser/ui/panels/panel_browser_view.h" | 13 #include "chrome/browser/ui/panels/panel_browser_view.h" |
14 #include "chrome/browser/ui/panels/panel_manager.h" | 14 #include "chrome/browser/ui/panels/panel_manager.h" |
15 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h" | 15 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
16 #include "chrome/browser/web_applications/web_app.h" | 16 #include "chrome/browser/web_applications/web_app.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "ui/base/animation/slide_animation.h" | 22 #include "ui/base/animation/slide_animation.h" |
23 #include "views/controls/button/image_button.h" | 23 #include "views/controls/button/image_button.h" |
24 #include "views/controls/button/menu_button.h" | 24 #include "views/controls/button/menu_button.h" |
25 #include "views/controls/image_view.h" | 25 #include "views/controls/image_view.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, | 90 EXPECT_EQ(PanelBrowserFrameView::PAINT_AS_INACTIVE, |
91 frame_view2->paint_state_); | 91 frame_view2->paint_state_); |
92 | 92 |
93 panel1->Close(); | 93 panel1->Close(); |
94 panel2->Close(); | 94 panel2->Close(); |
95 } | 95 } |
96 | 96 |
97 // We put all the testing logic in this class instead of the test so that | 97 // We put all the testing logic in this class instead of the test so that |
98 // we do not need to declare each new test as a friend of PanelBrowserView | 98 // we do not need to declare each new test as a friend of PanelBrowserView |
99 // for the purpose of accessing its private members. | 99 // for the purpose of accessing its private members. |
100 void TestMinimizeAndRestore(bool enable_auto_hiding) { | 100 void TestMinimizeAndRestore(bool enable_auto_hiding) { |
prasadt
2011/09/22 18:36:41
Do we still need this test now that PanelBrowserTe
| |
101 PanelManager* panel_manager = PanelManager::GetInstance(); | 101 PanelManager* panel_manager = PanelManager::GetInstance(); |
102 int expected_bottom_on_minimized = testing_work_area().height(); | 102 int expected_bottom_on_minimized = testing_work_area().height(); |
103 int expected_bottom_on_unminimized = expected_bottom_on_minimized; | 103 int expected_bottom_on_unminimized = expected_bottom_on_minimized; |
104 | 104 |
105 // Turn on auto-hiding if requested. | 105 // Turn on auto-hiding if requested. |
106 static const int bottom_thickness = 40; | 106 static const int bottom_thickness = 40; |
107 mock_auto_hiding_desktop_bar()->EnableAutoHiding( | 107 mock_auto_hiding_desktop_bar()->EnableAutoHiding( |
108 AutoHidingDesktopBar::ALIGN_BOTTOM, | 108 AutoHidingDesktopBar::ALIGN_BOTTOM, |
109 enable_auto_hiding, | 109 enable_auto_hiding, |
110 bottom_thickness); | 110 bottom_thickness); |
111 if (enable_auto_hiding) | 111 if (enable_auto_hiding) |
112 expected_bottom_on_unminimized -= bottom_thickness; | 112 expected_bottom_on_unminimized -= bottom_thickness; |
113 | 113 |
114 // Create and test one panel first. | 114 // Create and test one panel first. |
115 Panel* panel1 = CreatePanel("PanelTest1"); | 115 Panel* panel1 = CreatePanel("PanelTest1"); |
116 PanelBrowserView* browser_view1 = GetBrowserView(panel1); | 116 PanelBrowserView* browser_view1 = GetBrowserView(panel1); |
117 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); | 117 PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView(); |
118 | 118 |
119 // Test minimizing/restoring an individual panel. | 119 // Test minimizing/restoring an individual panel. |
120 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); | 120 EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state()); |
121 int initial_height = panel1->GetBounds().height(); | 121 int initial_height = panel1->GetBounds().height(); |
122 int titlebar_height = frame_view1->NonClientTopBorderHeight(); | 122 int titlebar_height = frame_view1->NonClientTopBorderHeight(); |
123 | 123 |
124 panel1->SetExpansionState(Panel::MINIMIZED); | 124 panel1->SetExpansionState(Panel::MINIMIZED); |
125 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); | 125 EXPECT_EQ(Panel::MINIMIZED, panel1->expansion_state()); |
126 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); | 126 EXPECT_LT(panel1->GetBounds().height(), titlebar_height); |
127 EXPECT_GT(panel1->GetBounds().height(), 0); | 127 EXPECT_GT(panel1->GetBounds().height(), 0); |
128 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); | 128 EXPECT_EQ(expected_bottom_on_minimized, panel1->GetBounds().bottom()); |
129 EXPECT_TRUE(IsMouseWatcherStarted()); | 129 EXPECT_TRUE(PanelMouseWatcher::GetInstance()->IsSubscribed(browser_view1)); |
130 WaitTillBoundsAnimationFinished(browser_view1); | 130 WaitTillBoundsAnimationFinished(browser_view1); |
131 EXPECT_FALSE(panel1->IsActive()); | 131 EXPECT_FALSE(panel1->IsActive()); |
132 | 132 |
133 panel1->SetExpansionState(Panel::TITLE_ONLY); | 133 panel1->SetExpansionState(Panel::TITLE_ONLY); |
134 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); | 134 EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state()); |
135 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); | 135 EXPECT_EQ(titlebar_height, panel1->GetBounds().height()); |
136 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); | 136 EXPECT_EQ(expected_bottom_on_unminimized, panel1->GetBounds().bottom()); |
137 WaitTillBoundsAnimationFinished(browser_view1); | 137 WaitTillBoundsAnimationFinished(browser_view1); |
138 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); | 138 EXPECT_TRUE(frame_view1->close_button_->IsVisible()); |
139 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); | 139 EXPECT_TRUE(frame_view1->title_icon_->IsVisible()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( | 202 EXPECT_FALSE(panel_manager->ShouldBringUpTitlebars( |
203 0, 0)); | 203 0, 0)); |
204 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); | 204 browser_view1->OnTitlebarMousePressed(panel1->GetBounds().origin()); |
205 browser_view1->OnTitlebarMouseDragged( | 205 browser_view1->OnTitlebarMouseDragged( |
206 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); | 206 panel1->GetBounds().origin().Subtract(gfx::Point(5, 5))); |
207 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( | 207 EXPECT_TRUE(panel_manager->ShouldBringUpTitlebars( |
208 0, 0)); | 208 0, 0)); |
209 browser_view1->OnTitlebarMouseReleased(); | 209 browser_view1->OnTitlebarMouseReleased(); |
210 | 210 |
211 panel1->Close(); | 211 panel1->Close(); |
212 EXPECT_TRUE(IsMouseWatcherStarted()); | |
213 panel2->Close(); | 212 panel2->Close(); |
214 EXPECT_TRUE(IsMouseWatcherStarted()); | |
215 panel3->Close(); | 213 panel3->Close(); |
216 EXPECT_FALSE(IsMouseWatcherStarted()); | |
217 } | 214 } |
218 | 215 |
219 void TestDrawAttention() { | 216 void TestDrawAttention() { |
220 Panel* panel = CreatePanel("PanelTest"); | 217 Panel* panel = CreatePanel("PanelTest"); |
221 PanelBrowserView* browser_view = GetBrowserView(panel); | 218 PanelBrowserView* browser_view = GetBrowserView(panel); |
222 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 219 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
223 SkColor attention_color = frame_view->GetTitleColor( | 220 SkColor attention_color = frame_view->GetTitleColor( |
224 PanelBrowserFrameView::PAINT_FOR_ATTENTION); | 221 PanelBrowserFrameView::PAINT_FOR_ATTENTION); |
225 | 222 |
226 // Test that the attention should not be drawn if the expanded panel is in | 223 // Test that the attention should not be drawn if the expanded panel is in |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 | 444 |
448 // TODO(jianli): Investigate why this fails on win trunk build. | 445 // TODO(jianli): Investigate why this fails on win trunk build. |
449 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { | 446 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { |
450 TestDrawAttention(); | 447 TestDrawAttention(); |
451 } | 448 } |
452 | 449 |
453 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { | 450 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { |
454 TestChangeAutoHideTaskBarThickness(); | 451 TestChangeAutoHideTaskBarThickness(); |
455 } | 452 } |
456 #endif | 453 #endif |
OLD | NEW |