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

Side by Side Diff: ash/system/tray/system_tray_unittest.cc

Issue 10384178: ash: Make sure all the sub-popups retain the same height as the main popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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
« no previous file with comments | « ash/system/tray/system_tray_item.cc ('k') | ash/system/tray/tray_details_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ash/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/system/tray/system_tray_item.h" 9 #include "ash/system/tray/system_tray_item.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ui/views/view.h" 11 #include "ui/views/view.h"
12 #include "ui/views/widget/widget.h"
12 13
13 namespace ash { 14 namespace ash {
14 namespace test { 15 namespace test {
15 16
16 namespace { 17 namespace {
17 18
18 SystemTray* CreateSystemTray() { 19 SystemTray* CreateSystemTray() {
19 SystemTray* tray = new SystemTray; 20 SystemTray* tray = new SystemTray;
20 tray->CreateItems(); 21 tray->CreateItems();
21 tray->CreateWidget(); 22 tray->CreateWidget();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 80 };
80 81
81 } // namespace 82 } // namespace
82 83
83 typedef AshTestBase SystemTrayTest; 84 typedef AshTestBase SystemTrayTest;
84 85
85 TEST_F(SystemTrayTest, SystemTrayDefaultView) { 86 TEST_F(SystemTrayTest, SystemTrayDefaultView) {
86 scoped_ptr<SystemTray> tray(CreateSystemTray()); 87 scoped_ptr<SystemTray> tray(CreateSystemTray());
87 ASSERT_TRUE(tray->widget()); 88 ASSERT_TRUE(tray->widget());
88 89
89 tray->ShowDefaultView(); 90 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
90 91
91 // Ensure that closing the bubble destroys it. 92 // Ensure that closing the bubble destroys it.
92 ASSERT_TRUE(tray->CloseBubbleForTest()); 93 ASSERT_TRUE(tray->CloseBubbleForTest());
93 RunAllPendingInMessageLoop(); 94 RunAllPendingInMessageLoop();
94 ASSERT_FALSE(tray->CloseBubbleForTest()); 95 ASSERT_FALSE(tray->CloseBubbleForTest());
95 } 96 }
96 97
97 TEST_F(SystemTrayTest, SystemTrayTestItems) { 98 TEST_F(SystemTrayTest, SystemTrayTestItems) {
98 scoped_ptr<SystemTray> tray(CreateSystemTray()); 99 scoped_ptr<SystemTray> tray(CreateSystemTray());
99 ASSERT_TRUE(tray->widget()); 100 ASSERT_TRUE(tray->widget());
100 101
101 TestItem* test_item = new TestItem; 102 TestItem* test_item = new TestItem;
102 TestItem* detailed_item = new TestItem; 103 TestItem* detailed_item = new TestItem;
103 tray->AddTrayItem(test_item); 104 tray->AddTrayItem(test_item);
104 tray->AddTrayItem(detailed_item); 105 tray->AddTrayItem(detailed_item);
105 106
106 // Ensure the tray views are created. 107 // Ensure the tray views are created.
107 ASSERT_TRUE(test_item->tray_view() != NULL); 108 ASSERT_TRUE(test_item->tray_view() != NULL);
108 ASSERT_TRUE(detailed_item->tray_view() != NULL); 109 ASSERT_TRUE(detailed_item->tray_view() != NULL);
109 110
110 // Ensure a default views are created. 111 // Ensure a default views are created.
111 tray->ShowDefaultView(); 112 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
112 ASSERT_TRUE(test_item->default_view() != NULL); 113 ASSERT_TRUE(test_item->default_view() != NULL);
113 ASSERT_TRUE(detailed_item->default_view() != NULL); 114 ASSERT_TRUE(detailed_item->default_view() != NULL);
114 115
115 // Show the detailed view, ensure it's created and the default view destroyed. 116 // Show the detailed view, ensure it's created and the default view destroyed.
116 tray->ShowDetailedView(detailed_item, 0, false); 117 tray->ShowDetailedView(detailed_item, 0, false, BUBBLE_CREATE_NEW);
117 RunAllPendingInMessageLoop(); 118 RunAllPendingInMessageLoop();
118 ASSERT_TRUE(test_item->default_view() == NULL); 119 ASSERT_TRUE(test_item->default_view() == NULL);
119 ASSERT_TRUE(detailed_item->detailed_view() != NULL); 120 ASSERT_TRUE(detailed_item->detailed_view() != NULL);
120 121
121 // Show the default view, ensure it's created and the detailed view destroyed. 122 // Show the default view, ensure it's created and the detailed view destroyed.
122 tray->ShowDefaultView(); 123 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
123 RunAllPendingInMessageLoop(); 124 RunAllPendingInMessageLoop();
124 ASSERT_TRUE(test_item->default_view() != NULL); 125 ASSERT_TRUE(test_item->default_view() != NULL);
125 ASSERT_TRUE(detailed_item->detailed_view() == NULL); 126 ASSERT_TRUE(detailed_item->detailed_view() == NULL);
126 } 127 }
127 128
128 // Disabled due to a use-after-free, see http://crbug.com/127539. 129 // Disabled due to a use-after-free, see http://crbug.com/127539.
129 TEST_F(SystemTrayTest, DISABLED_SystemTrayNotifications) { 130 TEST_F(SystemTrayTest, DISABLED_SystemTrayNotifications) {
130 scoped_ptr<SystemTray> tray(CreateSystemTray()); 131 scoped_ptr<SystemTray> tray(CreateSystemTray());
131 ASSERT_TRUE(tray->widget()); 132 ASSERT_TRUE(tray->widget());
132 133
133 TestItem* test_item = new TestItem; 134 TestItem* test_item = new TestItem;
134 TestItem* detailed_item = new TestItem; 135 TestItem* detailed_item = new TestItem;
135 tray->AddTrayItem(test_item); 136 tray->AddTrayItem(test_item);
136 tray->AddTrayItem(detailed_item); 137 tray->AddTrayItem(detailed_item);
137 138
138 // Ensure the tray views are created. 139 // Ensure the tray views are created.
139 ASSERT_TRUE(test_item->tray_view() != NULL); 140 ASSERT_TRUE(test_item->tray_view() != NULL);
140 ASSERT_TRUE(detailed_item->tray_view() != NULL); 141 ASSERT_TRUE(detailed_item->tray_view() != NULL);
141 142
142 // Ensure a notification view is created. 143 // Ensure a notification view is created.
143 tray->ShowNotificationView(test_item); 144 tray->ShowNotificationView(test_item);
144 ASSERT_TRUE(test_item->notification_view() != NULL); 145 ASSERT_TRUE(test_item->notification_view() != NULL);
145 146
146 // Show the default view, ensure the notification view is destroyed. 147 // Show the default view, ensure the notification view is destroyed.
147 tray->ShowDefaultView(); 148 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
148 RunAllPendingInMessageLoop(); 149 RunAllPendingInMessageLoop();
149 ASSERT_TRUE(test_item->notification_view() == NULL); 150 ASSERT_TRUE(test_item->notification_view() == NULL);
150 151
151 // Show the detailed view, ensure the notificaiton view is created again. 152 // Show the detailed view, ensure the notificaiton view is created again.
152 tray->ShowDetailedView(detailed_item, 0, false); 153 tray->ShowDetailedView(detailed_item, 0, false, BUBBLE_CREATE_NEW);
153 RunAllPendingInMessageLoop(); 154 RunAllPendingInMessageLoop();
154 ASSERT_TRUE(detailed_item->detailed_view() != NULL); 155 ASSERT_TRUE(detailed_item->detailed_view() != NULL);
155 ASSERT_TRUE(test_item->notification_view() != NULL); 156 ASSERT_TRUE(test_item->notification_view() != NULL);
156 157
157 // Hide the detailed view, ensure the notificaiton view still exists. 158 // Hide the detailed view, ensure the notificaiton view still exists.
158 ASSERT_TRUE(tray->CloseBubbleForTest()); 159 ASSERT_TRUE(tray->CloseBubbleForTest());
159 RunAllPendingInMessageLoop(); 160 RunAllPendingInMessageLoop();
160 ASSERT_TRUE(detailed_item->detailed_view() == NULL); 161 ASSERT_TRUE(detailed_item->detailed_view() == NULL);
161 ASSERT_TRUE(test_item->notification_view() != NULL); 162 ASSERT_TRUE(test_item->notification_view() != NULL);
162 } 163 }
163 164
165 TEST_F(SystemTrayTest, BubbleCreationTypesTest) {
166 scoped_ptr<SystemTray> tray(CreateSystemTray());
167 ASSERT_TRUE(tray->widget());
168
169 TestItem* test_item = new TestItem;
170 tray->AddTrayItem(test_item);
171
172 // Ensure the tray views are created.
173 ASSERT_TRUE(test_item->tray_view() != NULL);
174
175 // Show the default view, ensure the notification view is destroyed.
176 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
177 RunAllPendingInMessageLoop();
178
179 views::Widget* widget = test_item->default_view()->GetWidget();
180 gfx::Rect bubble_bounds = widget->GetWindowScreenBounds();
181
182 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
183 RunAllPendingInMessageLoop();
184
185 EXPECT_FALSE(test_item->default_view());
186
187 EXPECT_EQ(bubble_bounds.ToString(), test_item->detailed_view()->GetWidget()->
188 GetWindowScreenBounds().ToString());
189 EXPECT_EQ(widget, test_item->detailed_view()->GetWidget());
190
191 tray->ShowDefaultView(BUBBLE_USE_EXISTING);
192 RunAllPendingInMessageLoop();
193
194 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()->
195 GetWindowScreenBounds().ToString());
196 EXPECT_EQ(widget, test_item->default_view()->GetWidget());
197 }
198
164 } // namespace test 199 } // namespace test
165 } // namespace ash 200 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_item.cc ('k') | ash/system/tray/tray_details_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698