Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: chrome/browser/ui/panels/old_detached_panel_browsertest.cc

Issue 10908153: [Panel refactor] Deprecate old panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix views compile, no need to delete extra mac menu items cuz not using browser command updater any… Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/message_loop.h"
6 #include "chrome/browser/ui/panels/old_base_panel_browser_test.h"
7 #include "chrome/browser/ui/panels/detached_panel_strip.h"
8 #include "chrome/browser/ui/panels/native_panel.h"
9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_manager.h"
11
12 class OldDetachedPanelBrowserTest : public OldBasePanelBrowserTest {
13 };
14
15 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest,
16 CheckDetachedPanelProperties) {
17 PanelManager* panel_manager = PanelManager::GetInstance();
18 DetachedPanelStrip* detached_strip = panel_manager->detached_strip();
19
20 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
21 scoped_ptr<NativePanelTesting> panel_testing(
22 CreateNativePanelTesting(panel));
23
24 EXPECT_EQ(1, panel_manager->num_panels());
25 EXPECT_TRUE(detached_strip->HasPanel(panel));
26
27 EXPECT_FALSE(panel->always_on_top());
28
29 EXPECT_TRUE(panel_testing->IsButtonVisible(panel::CLOSE_BUTTON));
30 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::MINIMIZE_BUTTON));
31 EXPECT_FALSE(panel_testing->IsButtonVisible(panel::RESTORE_BUTTON));
32
33 EXPECT_EQ(panel::RESIZABLE_ALL_SIDES, panel->CanResizeByMouse());
34
35 Panel::AttentionMode expected_attention_mode =
36 static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
37 Panel::USE_SYSTEM_ATTENTION);
38 EXPECT_EQ(expected_attention_mode, panel->attention_mode());
39
40 panel_manager->CloseAll();
41 }
42
43 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, DrawAttentionOnActive) {
44 // Create a detached panel that is initially active.
45 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
46 scoped_ptr<NativePanelTesting> native_panel_testing(
47 CreateNativePanelTesting(panel));
48
49 // Test that the attention should not be drawn if the detached panel is in
50 // focus.
51 EXPECT_TRUE(panel->IsActive());
52 EXPECT_FALSE(panel->IsDrawingAttention());
53 panel->FlashFrame(true);
54 EXPECT_FALSE(panel->IsDrawingAttention());
55 MessageLoop::current()->RunAllPending();
56 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
57
58 panel->Close();
59 }
60
61 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest,
62 DrawAttentionOnInactive) {
63 // Create an inactive detached panel.
64 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
65 panel->Deactivate();
66 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
67
68 scoped_ptr<NativePanelTesting> native_panel_testing(
69 CreateNativePanelTesting(panel));
70
71 // Test that the attention is drawn when the detached panel is not in focus.
72 EXPECT_FALSE(panel->IsActive());
73 EXPECT_FALSE(panel->IsDrawingAttention());
74 panel->FlashFrame(true);
75 EXPECT_TRUE(panel->IsDrawingAttention());
76 MessageLoop::current()->RunAllPending();
77 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention());
78
79 // Stop drawing attention.
80 panel->FlashFrame(false);
81 EXPECT_FALSE(panel->IsDrawingAttention());
82 MessageLoop::current()->RunAllPending();
83 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
84
85 panel->Close();
86 }
87
88 // http://crbug.com/133464
89 #if defined(OS_LINUX)
90 #define MAYBE_DrawAttentionResetOnActivate DISABLED_DrawAttentionResetOnActivate
91 #else
92 #define MAYBE_DrawAttentionResetOnActivate DrawAttentionResetOnActivate
93 #endif
94
95 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest,
96 MAYBE_DrawAttentionResetOnActivate) {
97 // Create 2 panels so we end up with an inactive panel that can
98 // be made to draw attention.
99 Panel* panel1 = CreatePanel("test panel1");
100 Panel* panel2 = CreatePanel("test panel2");
101
102 scoped_ptr<NativePanelTesting> native_panel_testing(
103 CreateNativePanelTesting(panel1));
104
105 // Test that the attention is drawn when the detached panel is not in focus.
106 panel1->FlashFrame(true);
107 EXPECT_TRUE(panel1->IsDrawingAttention());
108 MessageLoop::current()->RunAllPending();
109 EXPECT_TRUE(native_panel_testing->VerifyDrawingAttention());
110
111 // Test that the attention is cleared when panel gets focus.
112 panel1->Activate();
113 WaitForPanelActiveState(panel1, SHOW_AS_ACTIVE);
114 EXPECT_FALSE(panel1->IsDrawingAttention());
115 EXPECT_FALSE(native_panel_testing->VerifyDrawingAttention());
116
117 panel1->Close();
118 panel2->Close();
119 }
120
121 #if defined(OS_LINUX)
122 // http://crbug.com/145740
123 #define MAYBE_ClickTitlebar FLAKY_ClickTitlebar
124 #else
125 #define MAYBE_ClickTitlebar ClickTitlebar
126 #endif
127 IN_PROC_BROWSER_TEST_F(OldDetachedPanelBrowserTest, MAYBE_ClickTitlebar) {
128 PanelManager* panel_manager = PanelManager::GetInstance();
129
130 Panel* panel = CreateDetachedPanel("1", gfx::Rect(300, 200, 250, 200));
131 EXPECT_TRUE(panel->IsActive());
132 EXPECT_FALSE(panel->IsMinimized());
133
134 // Clicking on an active detached panel's titlebar has no effect, regardless
135 // of modifier.
136 scoped_ptr<NativePanelTesting> test_panel(
137 CreateNativePanelTesting(panel));
138 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin());
139 test_panel->ReleaseMouseButtonTitlebar();
140 EXPECT_TRUE(panel->IsActive());
141 EXPECT_FALSE(panel->IsMinimized());
142
143 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin(),
144 panel::APPLY_TO_ALL);
145 test_panel->ReleaseMouseButtonTitlebar(panel::APPLY_TO_ALL);
146 EXPECT_TRUE(panel->IsActive());
147 EXPECT_FALSE(panel->IsMinimized());
148
149 // Create a second panel to cause the first to become inactive.
150 CreateDetachedPanel("2", gfx::Rect(100, 200, 230, 345));
151 WaitForPanelActiveState(panel, SHOW_AS_INACTIVE);
152
153 // Clicking on an inactive detached panel's titlebar activates it.
154 test_panel->PressLeftMouseButtonTitlebar(panel->GetBounds().origin());
155 test_panel->ReleaseMouseButtonTitlebar();
156 WaitForPanelActiveState(panel, SHOW_AS_ACTIVE);
157 EXPECT_FALSE(panel->IsMinimized());
158
159 panel_manager->CloseAll();
160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698