Chromium Code Reviews| Index: ash/test/test_shell_delegate.cc |
| diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc |
| index 26c196409f4498983b668f938691f81b128d63b8..738026f71f0669c055f1b338c3c21c26410b8e6c 100644 |
| --- a/ash/test/test_shell_delegate.cc |
| +++ b/ash/test/test_shell_delegate.cc |
| @@ -10,7 +10,11 @@ |
| #include "ash/gpu_support_stub.h" |
| #include "ash/palette_delegate.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| +#include "ash/root_window_controller.h" |
| #include "ash/session/session_state_delegate.h" |
| +#include "ash/shelf/wm_shelf.h" |
| +#include "ash/shell.h" |
| +#include "ash/shell_observer.h" |
| #include "ash/system/tray/system_tray_notifier.h" |
| #include "ash/test/test_keyboard_ui.h" |
| #include "ash/test/test_session_state_delegate.h" |
| @@ -19,6 +23,7 @@ |
| #include "ash/test/test_wallpaper_delegate.h" |
| #include "ash/wm/window_state.h" |
| #include "ash/wm/window_util.h" |
| +#include "ash/wm_window.h" |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| #include "ui/aura/window.h" |
| @@ -27,6 +32,29 @@ |
| namespace ash { |
| namespace test { |
| +// A ShellObserver that sets the shelf alignment and auto hide behavior when the |
| +// shelf is created, to simulate ChromeLauncherController's behavior. |
|
James Cook
2017/04/17 23:59:02
Aside: Yuck. I wish we didn't need this.
msw
2017/04/18 01:07:04
Acknowledged.
|
| +class ShelfInitializer : public ShellObserver { |
| + public: |
| + ShelfInitializer() { ash::Shell::Get()->AddShellObserver(this); } |
|
James Cook
2017/04/17 23:59:02
nit: ash:: not needed?
msw
2017/04/18 01:07:04
Done.
|
| + ~ShelfInitializer() override { ash::Shell::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. |
|
James Cook
2017/04/17 23:59:02
Aside: Double yuck.
msw
2017/04/18 01:07:04
Acknowledged.
|
| + 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); |
| +}; |
| + |
| TestShellDelegate::TestShellDelegate() |
| : num_exit_requests_(0), |
| multi_profiles_enabled_(false), |
| @@ -74,6 +102,8 @@ keyboard::KeyboardUI* TestShellDelegate::CreateKeyboardUI() { |
| void TestShellDelegate::OpenUrlFromArc(const GURL& url) {} |
| ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) { |
| + // Create a separate shelf initializer that mimics ChromeLauncherController. |
| + shelf_initializer_ = base::MakeUnique<ShelfInitializer>(); |
| return new TestShelfDelegate(); |
| } |