Chromium Code Reviews| Index: ash/common/test/test_shelf_delegate.cc |
| diff --git a/ash/common/test/test_shelf_delegate.cc b/ash/common/test/test_shelf_delegate.cc |
| index 0c166c4e497024fbc52e06e59d4b897ba6452e0d..f206e3c2252ef597e487265177bd7949221c1e9f 100644 |
| --- a/ash/common/test/test_shelf_delegate.cc |
| +++ b/ash/common/test/test_shelf_delegate.cc |
| @@ -7,9 +7,13 @@ |
| #include <utility> |
| #include "ash/common/shelf/shelf_model.h" |
| +#include "ash/common/shelf/wm_shelf.h" |
| +#include "ash/common/shell_observer.h" |
| #include "ash/common/test/test_shelf_item_delegate.h" |
| +#include "ash/common/wm_shell.h" |
| #include "ash/common/wm_window.h" |
| #include "ash/common/wm_window_property.h" |
| +#include "ash/root_window_controller.h" |
| #include "base/memory/ptr_util.h" |
| namespace ash { |
| @@ -17,9 +21,33 @@ namespace test { |
| TestShelfDelegate* TestShelfDelegate::instance_ = nullptr; |
| +// A ShellObserver that sets the shelf alignment and auto hide behavior when the |
| +// shelf is created, to simulate ChromeLauncherController's behavior. |
| +class ShelfInitializer : public ShellObserver { |
| + public: |
| + ShelfInitializer() { WmShell::Get()->AddShellObserver(this); } |
| + ~ShelfInitializer() override { WmShell::Get()->RemoveShellObserver(this); } |
| + |
| + // ShellObserver: |
| + void OnShelfCreatedForRootWindow(WmWindow* root_window) override { |
| + WmShelf* shelf = root_window->GetRootWindowController()->GetShelf(); |
| + // Do not override the custom initialization performed by some unit tests. |
| + if (shelf->alignment() == SHELF_ALIGNMENT_BOTTOM_LOCKED && |
| + shelf->auto_hide_behavior() == SHELF_AUTO_HIDE_ALWAYS_HIDDEN) { |
| + shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| + shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| + shelf->UpdateVisibilityState(); |
| + } |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ShelfInitializer); |
| +}; |
| + |
| TestShelfDelegate::TestShelfDelegate(ShelfModel* model) : model_(model) { |
| CHECK(!instance_); |
| instance_ = this; |
| + shelf_initializer_ = base::MakeUnique<ShelfInitializer>(); |
|
James Cook
2017/02/14 01:38:03
Can this go in the initializer list? If not, comme
msw
2017/02/14 05:13:18
Done.
|
| } |
| TestShelfDelegate::~TestShelfDelegate() { |