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

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

Issue 2017413002: ash: Fix variable names and setters in ShelfLayoutManager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shellshelf
Patch Set: rebase Created 4 years, 6 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
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/accessibility_delegate.h" 9 #include "ash/accessibility_delegate.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
msw 2016/06/01 00:53:24 nit: include shelf.h instead?
James Cook 2016/06/01 15:53:06 Done.
12 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/system/status_area_widget.h" 14 #include "ash/system/status_area_widget.h"
15 #include "ash/system/tray/system_tray_bubble.h" 15 #include "ash/system/tray/system_tray_bubble.h"
16 #include "ash/system/tray/system_tray_item.h" 16 #include "ash/system/tray/system_tray_item.h"
17 #include "ash/system/tray/tray_constants.h" 17 #include "ash/system/tray/tray_constants.h"
18 #include "ash/system/tray/tray_popup_item_container.h" 18 #include "ash/system/tray/tray_popup_item_container.h"
19 #include "ash/system/web_notification/web_notification_tray.h" 19 #include "ash/system/web_notification/web_notification_tray.h"
20 #include "ash/test/ash_test_base.h" 20 #include "ash/test/ash_test_base.h"
21 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 ASSERT_TRUE(tray->CloseSystemBubble()); 176 ASSERT_TRUE(tray->CloseSystemBubble());
177 RunAllPendingInMessageLoop(); 177 RunAllPendingInMessageLoop();
178 ASSERT_FALSE(tray->draw_background_as_active()); 178 ASSERT_FALSE(tray->draw_background_as_active());
179 } 179 }
180 180
181 // Closing the system bubble through an alignment change should change the 181 // Closing the system bubble through an alignment change should change the
182 // system tray coloring back to normal. 182 // system tray coloring back to normal.
183 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) { 183 TEST_F(SystemTrayTest, SystemTrayColoringAfterAlignmentChange) {
184 SystemTray* tray = GetSystemTray(); 184 SystemTray* tray = GetSystemTray();
185 ASSERT_TRUE(tray->GetWidget()); 185 ASSERT_TRUE(tray->GetWidget());
186 ShelfLayoutManager* manager = Shell::GetPrimaryRootWindowController() 186 Shelf* shelf = Shelf::ForPrimaryDisplay();
187 ->shelf_widget() 187 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
188 ->shelf_layout_manager();
189 manager->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
190 // At the beginning the tray coloring is not active. 188 // At the beginning the tray coloring is not active.
191 ASSERT_FALSE(tray->draw_background_as_active()); 189 ASSERT_FALSE(tray->draw_background_as_active());
192 190
193 // Showing the system bubble should show the background as active. 191 // Showing the system bubble should show the background as active.
194 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 192 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
195 ASSERT_TRUE(tray->draw_background_as_active()); 193 ASSERT_TRUE(tray->draw_background_as_active());
196 194
197 // Changing the alignment should close the system bubble and change the 195 // Changing the alignment should close the system bubble and change the
198 // background color. 196 // background color.
199 manager->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); 197 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
200 ASSERT_FALSE(tray->draw_background_as_active()); 198 ASSERT_FALSE(tray->draw_background_as_active());
201 RunAllPendingInMessageLoop(); 199 RunAllPendingInMessageLoop();
202 // The bubble should already be closed by now. 200 // The bubble should already be closed by now.
203 ASSERT_FALSE(tray->CloseSystemBubble()); 201 ASSERT_FALSE(tray->CloseSystemBubble());
204 } 202 }
205 203
206 TEST_F(SystemTrayTest, SystemTrayTestItems) { 204 TEST_F(SystemTrayTest, SystemTrayTestItems) {
207 SystemTray* tray = GetSystemTray(); 205 SystemTray* tray = GetSystemTray();
208 ASSERT_TRUE(tray->GetWidget()); 206 ASSERT_TRUE(tray->GetWidget());
209 207
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 RunAllPendingInMessageLoop(); 345 RunAllPendingInMessageLoop();
348 346
349 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()-> 347 EXPECT_EQ(bubble_bounds.ToString(), test_item->default_view()->GetWidget()->
350 GetWindowBoundsInScreen().ToString()); 348 GetWindowBoundsInScreen().ToString());
351 EXPECT_EQ(widget, test_item->default_view()->GetWidget()); 349 EXPECT_EQ(widget, test_item->default_view()->GetWidget());
352 } 350 }
353 351
354 // Tests that the tray is laid out properly and is fully contained within 352 // Tests that the tray is laid out properly and is fully contained within
355 // the shelf. 353 // the shelf.
356 TEST_F(SystemTrayTest, TrayBoundsInWidget) { 354 TEST_F(SystemTrayTest, TrayBoundsInWidget) {
357 ShelfLayoutManager* manager = Shell::GetPrimaryRootWindowController() 355 Shelf* shelf = Shelf::ForPrimaryDisplay();
358 ->shelf_widget()
359 ->shelf_layout_manager();
360 StatusAreaWidget* widget = Shell::GetPrimaryRootWindowController() 356 StatusAreaWidget* widget = Shell::GetPrimaryRootWindowController()
361 ->shelf_widget() 357 ->shelf_widget()
362 ->status_area_widget(); 358 ->status_area_widget();
363 SystemTray* tray = widget->system_tray(); 359 SystemTray* tray = widget->system_tray();
364 360
365 // Test in bottom alignment. 361 // Test in bottom alignment.
366 manager->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); 362 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
367 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen(); 363 gfx::Rect window_bounds = widget->GetWindowBoundsInScreen();
368 gfx::Rect tray_bounds = tray->GetBoundsInScreen(); 364 gfx::Rect tray_bounds = tray->GetBoundsInScreen();
369 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); 365 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
370 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); 366 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
371 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); 367 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
372 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); 368 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
373 369
374 // Test in locked alignment. 370 // Test in locked alignment.
375 manager->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED); 371 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED);
376 window_bounds = widget->GetWindowBoundsInScreen(); 372 window_bounds = widget->GetWindowBoundsInScreen();
377 tray_bounds = tray->GetBoundsInScreen(); 373 tray_bounds = tray->GetBoundsInScreen();
378 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); 374 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
379 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); 375 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
380 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); 376 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
381 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); 377 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
382 378
383 // Test in the left alignment. 379 // Test in the left alignment.
384 manager->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); 380 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
385 window_bounds = widget->GetWindowBoundsInScreen(); 381 window_bounds = widget->GetWindowBoundsInScreen();
386 tray_bounds = tray->GetBoundsInScreen(); 382 tray_bounds = tray->GetBoundsInScreen();
387 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); 383 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
388 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); 384 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
389 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); 385 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
390 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); 386 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
391 387
392 // Test in the right alignment. 388 // Test in the right alignment.
393 manager->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); 389 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
394 window_bounds = widget->GetWindowBoundsInScreen(); 390 window_bounds = widget->GetWindowBoundsInScreen();
395 tray_bounds = tray->GetBoundsInScreen(); 391 tray_bounds = tray->GetBoundsInScreen();
396 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom()); 392 EXPECT_TRUE(window_bounds.bottom() >= tray_bounds.bottom());
397 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right()); 393 EXPECT_TRUE(window_bounds.right() >= tray_bounds.right());
398 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x()); 394 EXPECT_TRUE(window_bounds.x() >= tray_bounds.x());
399 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y()); 395 EXPECT_TRUE(window_bounds.y() >= tray_bounds.y());
400 } 396 }
401 397
402 TEST_F(SystemTrayTest, PersistentBubble) { 398 TEST_F(SystemTrayTest, PersistentBubble) {
403 SystemTray* tray = GetSystemTray(); 399 SystemTray* tray = GetSystemTray();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 // Hide the default view, ensure the system tray height is back to zero. 569 // Hide the default view, ensure the system tray height is back to zero.
574 ASSERT_TRUE(tray->CloseSystemBubble()); 570 ASSERT_TRUE(tray->CloseSystemBubble());
575 RunAllPendingInMessageLoop(); 571 RunAllPendingInMessageLoop();
576 572
577 EXPECT_EQ(0, notification_tray->system_tray_height_for_test()); 573 EXPECT_EQ(0, notification_tray->system_tray_height_for_test());
578 } 574 }
579 #endif // OS_CHROMEOS 575 #endif // OS_CHROMEOS
580 576
581 } // namespace test 577 } // namespace test
582 } // namespace ash 578 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698