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

Side by Side Diff: ash/system/web_notification/web_notification_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/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 351
352 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) { 352 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) {
353 AddNotification("test_id"); 353 AddNotification("test_id");
354 EXPECT_TRUE(GetTray()->IsPopupVisible()); 354 EXPECT_TRUE(GetTray()->IsPopupVisible());
355 int bottom = GetPopupWorkAreaBottom(); 355 int bottom = GetPopupWorkAreaBottom();
356 356
357 // Shelf's auto-hide state won't be HIDDEN unless window exists. 357 // Shelf's auto-hide state won't be HIDDEN unless window exists.
358 std::unique_ptr<aura::Window> window( 358 std::unique_ptr<aura::Window> window(
359 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); 359 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
360 ShelfLayoutManager* shelf = 360 ShelfLayoutManager* shelf_layout_manager =
361 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 361 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
362 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 362 Shelf::ForPrimaryDisplay()->SetAutoHideBehavior(
363 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
363 364
364 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 365 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
365 int bottom_auto_hidden = GetPopupWorkAreaBottom(); 366 int bottom_auto_hidden = GetPopupWorkAreaBottom();
366 EXPECT_LT(bottom, bottom_auto_hidden); 367 EXPECT_LT(bottom, bottom_auto_hidden);
367 368
368 // Close the window, which shows the shelf. 369 // Close the window, which shows the shelf.
369 window.reset(); 370 window.reset();
370 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 371 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_layout_manager->auto_hide_state());
371 int bottom_auto_shown = GetPopupWorkAreaBottom(); 372 int bottom_auto_shown = GetPopupWorkAreaBottom();
372 EXPECT_EQ(bottom, bottom_auto_shown); 373 EXPECT_EQ(bottom, bottom_auto_shown);
373 374
374 // Create the system tray during auto-hide. 375 // Create the system tray during auto-hide.
375 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); 376 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
376 TestItem* test_item = new TestItem; 377 TestItem* test_item = new TestItem;
377 GetSystemTray()->AddTrayItem(test_item); 378 GetSystemTray()->AddTrayItem(test_item);
378 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 379 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
379 380
380 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 381 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_layout_manager->auto_hide_state());
381 EXPECT_TRUE(GetTray()->IsPopupVisible()); 382 EXPECT_TRUE(GetTray()->IsPopupVisible());
382 int bottom_with_tray = GetPopupWorkAreaBottom(); 383 int bottom_with_tray = GetPopupWorkAreaBottom();
383 EXPECT_GT(bottom_auto_shown, bottom_with_tray); 384 EXPECT_GT(bottom_auto_shown, bottom_with_tray);
384 385
385 // Create tray notification. 386 // Create tray notification.
386 GetSystemTray()->ShowNotificationView(test_item); 387 GetSystemTray()->ShowNotificationView(test_item);
387 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 388 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_layout_manager->auto_hide_state());
388 int bottom_with_tray_notification = GetPopupWorkAreaBottom(); 389 int bottom_with_tray_notification = GetPopupWorkAreaBottom();
389 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification); 390 EXPECT_GT(bottom_with_tray, bottom_with_tray_notification);
390 391
391 // Close the system tray. 392 // Close the system tray.
392 GetSystemTray()->ClickedOutsideBubble(); 393 GetSystemTray()->ClickedOutsideBubble();
393 shelf->UpdateAutoHideState(); 394 shelf_layout_manager->UpdateAutoHideState();
394 RunAllPendingInMessageLoop(); 395 RunAllPendingInMessageLoop();
395 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 396 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
396 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom(); 397 int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom();
397 EXPECT_LT(bottom_with_tray_notification, 398 EXPECT_LT(bottom_with_tray_notification,
398 bottom_hidden_with_tray_notification); 399 bottom_hidden_with_tray_notification);
399 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification); 400 EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification);
400 401
401 // Close the window again, which shows the shelf. 402 // Close the window again, which shows the shelf.
402 window.reset(); 403 window.reset();
403 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 404 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_layout_manager->auto_hide_state());
404 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); 405 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom();
405 EXPECT_GT(bottom_hidden_with_tray_notification, 406 EXPECT_GT(bottom_hidden_with_tray_notification,
406 bottom_shown_with_tray_notification); 407 bottom_shown_with_tray_notification);
407 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); 408 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification);
408 } 409 }
409 410
410 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) { 411 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) {
411 AddNotification("test_id"); 412 AddNotification("test_id");
412 EXPECT_TRUE(IsPopupVisible()); 413 EXPECT_TRUE(IsPopupVisible());
413 int bottom = GetPopupWorkAreaBottom(); 414 int bottom = GetPopupWorkAreaBottom();
414 415
415 // Checks the work area for normal auto-hidden state. 416 // Checks the work area for normal auto-hidden state.
416 std::unique_ptr<aura::Window> window( 417 std::unique_ptr<aura::Window> window(
417 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4))); 418 CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
418 ShelfLayoutManager* shelf = 419 Shelf* shelf = Shelf::ForPrimaryDisplay();
420 ShelfLayoutManager* shelf_layout_manager =
419 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); 421 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
420 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 422 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
421 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 423 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
422 int bottom_auto_hidden = GetPopupWorkAreaBottom(); 424 int bottom_auto_hidden = GetPopupWorkAreaBottom();
423 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 425 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
424 426
425 // Put |window| into fullscreen without forcing the shelf to hide. Currently, 427 // Put |window| into fullscreen without forcing the shelf to hide. Currently,
426 // this is used by immersive fullscreen and forces the shelf to be auto 428 // this is used by immersive fullscreen and forces the shelf to be auto
427 // hidden. 429 // hidden.
428 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false); 430 wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false);
429 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 431 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
430 RunAllPendingInMessageLoop(); 432 RunAllPendingInMessageLoop();
431 433
432 // The work area for auto-hidden status of fullscreen is a bit larger 434 // The work area for auto-hidden status of fullscreen is a bit larger
433 // since it doesn't even have the 3-pixel width. 435 // since it doesn't even have the 3-pixel width.
434 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
435 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom(); 437 int bottom_fullscreen_hidden = GetPopupWorkAreaBottom();
436 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden); 438 EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden);
437 439
438 // Move the mouse cursor at the bottom, which shows the shelf. 440 // Move the mouse cursor at the bottom, which shows the shelf.
439 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 441 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
440 gfx::Point bottom_right = 442 gfx::Point bottom_right =
441 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right(); 443 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom_right();
442 bottom_right.Offset(-1, -1); 444 bottom_right.Offset(-1, -1);
443 generator.MoveMouseTo(bottom_right); 445 generator.MoveMouseTo(bottom_right);
444 shelf->UpdateAutoHideStateNow(); 446 shelf_layout_manager->UpdateAutoHideStateNow();
445 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 447 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_layout_manager->auto_hide_state());
446 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); 448 EXPECT_EQ(bottom, GetPopupWorkAreaBottom());
447 449
448 generator.MoveMouseTo( 450 generator.MoveMouseTo(
449 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); 451 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint());
450 shelf->UpdateAutoHideStateNow(); 452 shelf_layout_manager->UpdateAutoHideStateNow();
451 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 453 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
452 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); 454 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom());
453 } 455 }
454 456
455 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) { 457 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) {
456 UpdateDisplay("800x600,600x400"); 458 UpdateDisplay("800x600,600x400");
457 459
458 AddNotification("test_id"); 460 AddNotification("test_id");
459 int bottom = GetPopupWorkAreaBottom(); 461 int bottom = GetPopupWorkAreaBottom();
460 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); 462 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray());
461 463
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, 526 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
525 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); 527 move.time_stamp()+base::TimeDelta::FromMilliseconds(50));
526 generator.Dispatch(&release); 528 generator.Dispatch(&release);
527 EXPECT_FALSE(tray->draw_background_as_active()); 529 EXPECT_FALSE(tray->draw_background_as_active());
528 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); 530 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
529 } 531 }
530 532
531 #endif // OS_CHROMEOS 533 #endif // OS_CHROMEOS
532 534
533 } // namespace ash 535 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698