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

Unified Diff: ash/test/test_shell_delegate.cc

Issue 2825533003: mash: Prerequisites for removing ShelfDelegate. (Closed)
Patch Set: Expand CheckWindowAndItemPlacement comment. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/test/test_shell_delegate.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..27c12b0530ba80e907b6e260e7980f04b36e0072 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.
+class ShelfInitializer : public ShellObserver {
+ public:
+ ShelfInitializer() { Shell::Get()->AddShellObserver(this); }
+ ~ShelfInitializer() override { 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.
+ 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();
}
« no previous file with comments | « ash/test/test_shell_delegate.h ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698