OLD | NEW |
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/status_area_widget.h" | 9 #include "ash/system/status_area_widget.h" |
10 #include "ash/system/tray/system_tray_item.h" | 10 #include "ash/system/tray/system_tray_item.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 131 tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
132 RunAllPendingInMessageLoop(); | 132 RunAllPendingInMessageLoop(); |
133 ASSERT_TRUE(test_item->default_view() != NULL); | 133 ASSERT_TRUE(test_item->default_view() != NULL); |
134 ASSERT_TRUE(detailed_item->detailed_view() == NULL); | 134 ASSERT_TRUE(detailed_item->detailed_view() == NULL); |
135 } | 135 } |
136 | 136 |
137 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { | 137 TEST_F(SystemTrayTest, TrayWidgetAutoResizes) { |
138 SystemTray* tray = GetSystemTray(); | 138 SystemTray* tray = GetSystemTray(); |
139 ASSERT_TRUE(tray->GetWidget()); | 139 ASSERT_TRUE(tray->GetWidget()); |
140 | 140 |
141 gfx::Size widget_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); | 141 // Add an initial tray item so that the tray gets laid out correctly. |
| 142 TestItem* initial_item = new TestItem; |
| 143 tray->AddTrayItem(initial_item); |
142 | 144 |
143 TestItem* test_item = new TestItem; | 145 gfx::Size initial_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); |
144 tray->AddTrayItem(test_item); | 146 |
| 147 TestItem* new_item = new TestItem; |
| 148 tray->AddTrayItem(new_item); |
145 | 149 |
146 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); | 150 gfx::Size new_size = tray->GetWidget()->GetWindowBoundsInScreen().size(); |
147 | 151 |
148 // Adding the new item should change the size of the tray. | 152 // Adding the new item should change the size of the tray. |
149 EXPECT_NE(widget_size.ToString(), new_size.ToString()); | 153 EXPECT_NE(initial_size.ToString(), new_size.ToString()); |
150 | 154 |
151 // Hiding the tray view of the new item should also change the size of the | 155 // Hiding the tray view of the new item should also change the size of the |
152 // tray. | 156 // tray. |
153 test_item->tray_view()->SetVisible(false); | 157 new_item->tray_view()->SetVisible(false); |
154 EXPECT_EQ(widget_size.ToString(), | 158 EXPECT_EQ(initial_size.ToString(), |
155 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 159 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
156 | 160 |
157 test_item->tray_view()->SetVisible(true); | 161 new_item->tray_view()->SetVisible(true); |
158 EXPECT_EQ(new_size.ToString(), | 162 EXPECT_EQ(new_size.ToString(), |
159 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); | 163 tray->GetWidget()->GetWindowBoundsInScreen().size().ToString()); |
160 } | 164 } |
161 | 165 |
162 TEST_F(SystemTrayTest, SystemTrayNotifications) { | 166 TEST_F(SystemTrayTest, SystemTrayNotifications) { |
163 SystemTray* tray = GetSystemTray(); | 167 SystemTray* tray = GetSystemTray(); |
164 ASSERT_TRUE(tray->GetWidget()); | 168 ASSERT_TRUE(tray->GetWidget()); |
165 | 169 |
166 TestItem* test_item = new TestItem; | 170 TestItem* test_item = new TestItem; |
167 TestItem* detailed_item = new TestItem; | 171 TestItem* detailed_item = new TestItem; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 tray->ShowDefaultView(BUBBLE_USE_EXISTING); | 227 tray->ShowDefaultView(BUBBLE_USE_EXISTING); |
224 RunAllPendingInMessageLoop(); | 228 RunAllPendingInMessageLoop(); |
225 | 229 |
226 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> | 230 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> |
227 GetWindowBoundsInScreen().ToString()); | 231 GetWindowBoundsInScreen().ToString()); |
228 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); | 232 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); |
229 } | 233 } |
230 | 234 |
231 } // namespace test | 235 } // namespace test |
232 } // namespace ash | 236 } // namespace ash |
OLD | NEW |