| Index: ash/shelf/shelf_widget_unittest.cc
|
| diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc
|
| index a99e41f69d03e6e64cc22b83d2c19d68563f4a9b..c1f778062f5cc3e90c8aee333a79e0eed7482b91 100644
|
| --- a/ash/shelf/shelf_widget_unittest.cc
|
| +++ b/ash/shelf/shelf_widget_unittest.cc
|
| @@ -6,16 +6,14 @@
|
|
|
| #include "ash/root_window_controller.h"
|
| #include "ash/shelf/shelf.h"
|
| -#include "ash/shelf/shelf_button.h"
|
| +#include "ash/shelf/shelf_delegate.h"
|
| #include "ash/shelf/shelf_layout_manager.h"
|
| -#include "ash/shelf/shelf_model.h"
|
| #include "ash/shelf/shelf_view.h"
|
| #include "ash/shell.h"
|
| #include "ash/test/ash_test_base.h"
|
| #include "ash/test/ash_test_helper.h"
|
| #include "ash/test/shelf_test_api.h"
|
| #include "ash/test/shelf_view_test_api.h"
|
| -#include "ash/test/test_shelf_delegate.h"
|
| #include "ash/test/test_shell_delegate.h"
|
| #include "ash/wm/window_util.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| @@ -319,9 +317,41 @@ TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
|
|
|
| namespace {
|
|
|
| -// A TestShellDelegate that attempts to set an initial shelf auto hide behavior
|
| -// when creating a ShelfDelegate, which simulates ChromeLauncherController's
|
| -// behavior.
|
| +// A TestShelfDelegate that sets the shelf alignment and auto hide behavior in
|
| +// OnShelfCreated, to simulate ChromeLauncherController's behavior.
|
| +class TestShelfDelegate : public ShelfDelegate {
|
| + public:
|
| + TestShelfDelegate(ShelfAlignment initial_alignment,
|
| + ShelfAutoHideBehavior initial_auto_hide_behavior)
|
| + : initial_alignment_(initial_alignment),
|
| + initial_auto_hide_behavior_(initial_auto_hide_behavior) {}
|
| + ~TestShelfDelegate() override {}
|
| +
|
| + // ShelfDelegate implementation.
|
| + void OnShelfCreated(Shelf* shelf) override {
|
| + shelf->SetAlignment(initial_alignment_);
|
| + shelf->SetAutoHideBehavior(initial_auto_hide_behavior_);
|
| + }
|
| + void OnShelfDestroyed(Shelf* shelf) override {}
|
| + void OnShelfAlignmentChanged(Shelf* shelf) override {}
|
| + void OnShelfAutoHideBehaviorChanged(Shelf* shelf) override {}
|
| + ShelfID GetShelfIDForAppID(const std::string& app_id) override { return 0; }
|
| + bool HasShelfIDToAppIDMapping(ShelfID id) const override { return false; }
|
| + const std::string& GetAppIDForShelfID(ShelfID id) override {
|
| + return base::EmptyString();
|
| + }
|
| + void PinAppWithID(const std::string& app_id) override {}
|
| + bool IsAppPinned(const std::string& app_id) override { return false; }
|
| + void UnpinAppWithID(const std::string& app_id) override {}
|
| +
|
| + private:
|
| + ShelfAlignment initial_alignment_;
|
| + ShelfAutoHideBehavior initial_auto_hide_behavior_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestShelfDelegate);
|
| +};
|
| +
|
| +// A TestShellDelegate that creates a TestShelfDelegate with initial values.
|
| class ShelfWidgetTestShellDelegate : public test::TestShellDelegate {
|
| public:
|
| ShelfWidgetTestShellDelegate() {}
|
| @@ -329,18 +359,21 @@ class ShelfWidgetTestShellDelegate : public test::TestShellDelegate {
|
|
|
| // test::TestShellDelegate
|
| ShelfDelegate* CreateShelfDelegate(ShelfModel* model) override {
|
| - ShelfDelegate* shelf_delegate = new test::TestShelfDelegate(model);
|
| - Shell::GetInstance()->SetShelfAutoHideBehavior(
|
| - initial_auto_hide_behavior_, Shell::GetPrimaryRootWindow());
|
| - return shelf_delegate;
|
| + return new TestShelfDelegate(initial_alignment_,
|
| + initial_auto_hide_behavior_);
|
| + }
|
| +
|
| + void set_initial_alignment(ShelfAlignment alignment) {
|
| + initial_alignment_ = alignment;
|
| }
|
|
|
| - void set_initial_auto_hide_behavior(ash::ShelfAutoHideBehavior behavior) {
|
| + void set_initial_auto_hide_behavior(ShelfAutoHideBehavior behavior) {
|
| initial_auto_hide_behavior_ = behavior;
|
| }
|
|
|
| private:
|
| - ash::ShelfAutoHideBehavior initial_auto_hide_behavior_ =
|
| + ShelfAlignment initial_alignment_ = SHELF_ALIGNMENT_BOTTOM;
|
| + ShelfAutoHideBehavior initial_auto_hide_behavior_ =
|
| SHELF_AUTO_HIDE_BEHAVIOR_NEVER;
|
| DISALLOW_COPY_AND_ASSIGN(ShelfWidgetTestShellDelegate);
|
| };
|
| @@ -358,10 +391,12 @@ class ShelfWidgetTestWithDelegate : public ShelfWidgetTest {
|
| ShelfWidgetTest::SetUp();
|
| }
|
|
|
| - void TestCreateShelfWithInitialAutoHideBehavior(
|
| - ash::ShelfAutoHideBehavior initial_auto_hide_behavior,
|
| + void TestCreateShelfWithInitialValues(
|
| + ShelfAlignment initial_alignment,
|
| + ShelfAutoHideBehavior initial_auto_hide_behavior,
|
| ShelfVisibilityState expected_shelf_visibility_state,
|
| ShelfAutoHideState expected_shelf_auto_hide_state) {
|
| + shelf_widget_test_shell_delegate_->set_initial_alignment(initial_alignment);
|
| shelf_widget_test_shell_delegate_->set_initial_auto_hide_behavior(
|
| initial_auto_hide_behavior);
|
| SetUserLoggedIn(true);
|
| @@ -375,6 +410,9 @@ class ShelfWidgetTestWithDelegate : public ShelfWidgetTest {
|
| shelf_widget->shelf_layout_manager();
|
| ASSERT_NE(nullptr, shelf_layout_manager);
|
|
|
| + EXPECT_EQ(initial_alignment, shelf_layout_manager->GetAlignment());
|
| + EXPECT_EQ(initial_auto_hide_behavior,
|
| + shelf_layout_manager->auto_hide_behavior());
|
| EXPECT_EQ(expected_shelf_visibility_state,
|
| shelf_layout_manager->visibility_state());
|
| EXPECT_EQ(expected_shelf_auto_hide_state,
|
| @@ -389,18 +427,24 @@ class ShelfWidgetTestWithDelegate : public ShelfWidgetTest {
|
| } // namespace
|
|
|
| TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysShelf) {
|
| - TestCreateShelfWithInitialAutoHideBehavior(
|
| - SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, SHELF_AUTO_HIDE, SHELF_AUTO_HIDE_HIDDEN);
|
| + // The actual auto hide state is shown because there are no open windows.
|
| + TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM,
|
| + SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
|
| + SHELF_AUTO_HIDE, SHELF_AUTO_HIDE_SHOWN);
|
| }
|
|
|
| TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideNeverShelf) {
|
| - TestCreateShelfWithInitialAutoHideBehavior(
|
| - SHELF_AUTO_HIDE_BEHAVIOR_NEVER, SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
|
| + // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
|
| + TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_LEFT,
|
| + SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
|
| + SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
|
| }
|
|
|
| TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysHideShelf) {
|
| - TestCreateShelfWithInitialAutoHideBehavior(
|
| - SHELF_AUTO_HIDE_ALWAYS_HIDDEN, SHELF_HIDDEN, SHELF_AUTO_HIDE_HIDDEN);
|
| + // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
|
| + TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_RIGHT,
|
| + SHELF_AUTO_HIDE_ALWAYS_HIDDEN, SHELF_HIDDEN,
|
| + SHELF_AUTO_HIDE_HIDDEN);
|
| }
|
|
|
| } // namespace ash
|
|
|