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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2824233003: Disallow toggling of shelf auto-hide with touch when there are no windows open (Closed)
Patch Set: Add UT. Created 3 years, 8 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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/public/cpp/config.h" 10 #include "ash/public/cpp/config.h"
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 // Swipe-up. This should not change anything. 543 // Swipe-up. This should not change anything.
544 end = start - delta; 544 end = start - delta;
545 generator.GestureScrollSequenceWithCallback( 545 generator.GestureScrollSequenceWithCallback(
546 below_start, end, kTimeDelta, kNumScrollSteps, 546 below_start, end, kTimeDelta, kNumScrollSteps,
547 base::Bind(&ShelfDragCallback::ProcessScroll, 547 base::Bind(&ShelfDragCallback::ProcessScroll,
548 base::Unretained(&handler))); 548 base::Unretained(&handler)));
549 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 549 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
550 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 550 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
551 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); 551 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString());
552 552
553 // Close actually, otherwise further event may be affected since widget 553 // Minimize actually, otherwise further event may be affected since widget
554 // is fullscreen status. 554 // is fullscreen status.
555 widget->Close(); 555 widget->Minimize();
556 RunAllPendingInMessageLoop(); 556 RunAllPendingInMessageLoop();
557 EXPECT_FALSE(layout_manager->HasVisibleWindow());
557 558
558 // The shelf should be shown because there are no more visible windows. 559 // The shelf should be shown because there are no more visible windows.
559 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 560 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
560 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 561 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
561 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 562 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
562 563
563 // Swipe-up to hide. This should have no effect because there are no visible 564 // Swipe-up to hide. This should have no effect because there are no visible
564 // windows. 565 // windows.
565 end = below_start - delta; 566 end = below_start - delta;
566 generator.GestureScrollSequenceWithCallback( 567 generator.GestureScrollSequenceWithCallback(
567 below_start, end, kTimeDelta, kNumScrollSteps, 568 below_start, end, kTimeDelta, kNumScrollSteps,
568 base::Bind(&ShelfDragCallback::ProcessScroll, 569 base::Bind(&ShelfDragCallback::ProcessScroll,
569 base::Unretained(&handler))); 570 base::Unretained(&handler)));
570 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 571 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
571 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 572 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
572 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 573 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
574 EXPECT_EQ(shelf_shown.ToString(),
575 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
576
577 // Swipe-down to hide. This should have no effect because there are no visible
578 // windows.
579 end = start + delta;
580 generator.GestureScrollSequenceWithCallback(
581 start, end, kTimeDelta, kNumScrollSteps,
582 base::Bind(&ShelfDragCallback::ProcessScroll,
583 base::Unretained(&handler)));
584 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
585 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
586 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
587 EXPECT_EQ(shelf_shown.ToString(),
588 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
589
590 widget->Restore();
591 RunAllPendingInMessageLoop();
592 EXPECT_TRUE(layout_manager->HasVisibleWindow());
593
594 // Swipe up on the shelf. This should show the shelf and disable auto-hide
595 // since there is one visible window.
596 end = below_start - delta;
597 generator.GestureScrollSequenceWithCallback(
598 below_start, end, kTimeDelta, kNumScrollSteps,
599 base::Bind(&ShelfDragCallback::ProcessScroll,
600 base::Unretained(&handler)));
601 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
602 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
603
604 // Close the widget to make sure the swiping on the shelf will not take
605 // effect.
606 widget->Close();
607 RunAllPendingInMessageLoop();
608 EXPECT_FALSE(layout_manager->HasVisibleWindow());
609
610 // Swipe-up to hide. This should have no effect because there are no visible
611 // windows.
612 generator.GestureScrollSequenceWithCallback(
613 below_start, end, kTimeDelta, kNumScrollSteps,
614 base::Bind(&ShelfDragCallback::ProcessScroll,
615 base::Unretained(&handler)));
616 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
617 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
618 EXPECT_EQ(shelf_shown.ToString(),
619 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
620
621 // Swipe-down to hide. This should have no effect because there are no visible
622 // windows.
xiaoyinh(OOO Sep 11-29) 2017/04/21 04:13:12 nit: EXPECT_FALSE(layout_manager->HasVisibleWindow
minch1 2017/04/21 16:42:42 No window opened after line 608. I think maybe the
623 end = start + delta;
624 generator.GestureScrollSequenceWithCallback(
625 start, end, kTimeDelta, kNumScrollSteps,
626 base::Bind(&ShelfDragCallback::ProcessScroll,
627 base::Unretained(&handler)));
628 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
629 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
630 EXPECT_EQ(shelf_shown.ToString(),
631 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
573 } 632 }
574 633
575 // Makes sure SetVisible updates work area and widget appropriately. 634 // Makes sure SetVisible updates work area and widget appropriately.
576 TEST_F(ShelfLayoutManagerTest, SetVisible) { 635 TEST_F(ShelfLayoutManagerTest, SetVisible) {
577 ShelfWidget* shelf_widget = GetShelfWidget(); 636 ShelfWidget* shelf_widget = GetShelfWidget();
578 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); 637 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager();
579 // Force an initial layout. 638 // Force an initial layout.
580 manager->LayoutShelf(); 639 manager->LayoutShelf();
581 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); 640 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state());
582 641
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 // Open keyboard in sticky mode. 1899 // Open keyboard in sticky mode.
1841 kb_controller->ShowKeyboard(true); 1900 kb_controller->ShowKeyboard(true);
1842 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 1901 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
1843 1902
1844 // Work area should be changed. 1903 // Work area should be changed.
1845 EXPECT_NE(orig_work_area, 1904 EXPECT_NE(orig_work_area,
1846 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1905 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1847 } 1906 }
1848 1907
1849 } // namespace ash 1908 } // namespace ash
OLDNEW
« ash/shelf/shelf_layout_manager.cc ('K') | « ash/shelf/shelf_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698