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.h" | 15 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(PanelMouseWatcher::GetInstance()->IsSubscribed(browser_view1)); | 129 EXPECT_TRUE(IsMouseWatcherStarted()); |
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()); |
212 panel2->Close(); | 213 panel2->Close(); |
| 214 EXPECT_TRUE(IsMouseWatcherStarted()); |
213 panel3->Close(); | 215 panel3->Close(); |
| 216 EXPECT_FALSE(IsMouseWatcherStarted()); |
214 } | 217 } |
215 | 218 |
216 void TestDrawAttention() { | 219 void TestDrawAttention() { |
217 Panel* panel = CreatePanel("PanelTest"); | 220 Panel* panel = CreatePanel("PanelTest"); |
218 PanelBrowserView* browser_view = GetBrowserView(panel); | 221 PanelBrowserView* browser_view = GetBrowserView(panel); |
219 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); | 222 PanelBrowserFrameView* frame_view = browser_view->GetFrameView(); |
220 SkColor attention_color = frame_view->GetTitleColor( | 223 SkColor attention_color = frame_view->GetTitleColor( |
221 PanelBrowserFrameView::PAINT_FOR_ATTENTION); | 224 PanelBrowserFrameView::PAINT_FOR_ATTENTION); |
222 | 225 |
223 // Test that the attention should not be drawn if the expanded panel is in | 226 // 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... |
444 | 447 |
445 // TODO(jianli): Investigate why this fails on win trunk build. | 448 // TODO(jianli): Investigate why this fails on win trunk build. |
446 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { | 449 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, DISABLED_DrawAttention) { |
447 TestDrawAttention(); | 450 TestDrawAttention(); |
448 } | 451 } |
449 | 452 |
450 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { | 453 IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, ChangeAutoHideTaskBarThickness) { |
451 TestChangeAutoHideTaskBarThickness(); | 454 TestChangeAutoHideTaskBarThickness(); |
452 } | 455 } |
453 #endif | 456 #endif |
OLD | NEW |