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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/test_shell_delegate.h" 5 #include "ash/test/test_shell_delegate.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "ash/default_accessibility_delegate.h" 9 #include "ash/default_accessibility_delegate.h"
10 #include "ash/gpu_support_stub.h" 10 #include "ash/gpu_support_stub.h"
11 #include "ash/palette_delegate.h" 11 #include "ash/palette_delegate.h"
12 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/root_window_controller.h"
13 #include "ash/session/session_state_delegate.h" 14 #include "ash/session/session_state_delegate.h"
15 #include "ash/shelf/wm_shelf.h"
16 #include "ash/shell.h"
17 #include "ash/shell_observer.h"
14 #include "ash/system/tray/system_tray_notifier.h" 18 #include "ash/system/tray/system_tray_notifier.h"
15 #include "ash/test/test_keyboard_ui.h" 19 #include "ash/test/test_keyboard_ui.h"
16 #include "ash/test/test_session_state_delegate.h" 20 #include "ash/test/test_session_state_delegate.h"
17 #include "ash/test/test_shelf_delegate.h" 21 #include "ash/test/test_shelf_delegate.h"
18 #include "ash/test/test_system_tray_delegate.h" 22 #include "ash/test/test_system_tray_delegate.h"
19 #include "ash/test/test_wallpaper_delegate.h" 23 #include "ash/test/test_wallpaper_delegate.h"
20 #include "ash/wm/window_state.h" 24 #include "ash/wm/window_state.h"
21 #include "ash/wm/window_util.h" 25 #include "ash/wm/window_util.h"
26 #include "ash/wm_window.h"
22 #include "base/logging.h" 27 #include "base/logging.h"
23 #include "base/memory/ptr_util.h" 28 #include "base/memory/ptr_util.h"
24 #include "ui/aura/window.h" 29 #include "ui/aura/window.h"
25 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
26 31
27 namespace ash { 32 namespace ash {
28 namespace test { 33 namespace test {
29 34
35 // A ShellObserver that sets the shelf alignment and auto hide behavior when the
36 // shelf is created, to simulate ChromeLauncherController's behavior.
37 class ShelfInitializer : public ShellObserver {
38 public:
39 ShelfInitializer() { Shell::Get()->AddShellObserver(this); }
40 ~ShelfInitializer() override { Shell::Get()->RemoveShellObserver(this); }
41
42 // ShellObserver:
43 void OnShelfCreatedForRootWindow(WmWindow* root_window) override {
44 WmShelf* shelf = root_window->GetRootWindowController()->GetShelf();
45 // Do not override the custom initialization performed by some unit tests.
46 if (shelf->alignment() == SHELF_ALIGNMENT_BOTTOM_LOCKED &&
47 shelf->auto_hide_behavior() == SHELF_AUTO_HIDE_ALWAYS_HIDDEN) {
48 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
49 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
50 shelf->UpdateVisibilityState();
51 }
52 }
53
54 private:
55 DISALLOW_COPY_AND_ASSIGN(ShelfInitializer);
56 };
57
30 TestShellDelegate::TestShellDelegate() 58 TestShellDelegate::TestShellDelegate()
31 : num_exit_requests_(0), 59 : num_exit_requests_(0),
32 multi_profiles_enabled_(false), 60 multi_profiles_enabled_(false),
33 force_maximize_on_first_run_(false), 61 force_maximize_on_first_run_(false),
34 touchscreen_enabled_in_local_pref_(true) {} 62 touchscreen_enabled_in_local_pref_(true) {}
35 63
36 TestShellDelegate::~TestShellDelegate() {} 64 TestShellDelegate::~TestShellDelegate() {}
37 65
38 ::service_manager::Connector* TestShellDelegate::GetShellConnector() const { 66 ::service_manager::Connector* TestShellDelegate::GetShellConnector() const {
39 return nullptr; 67 return nullptr;
(...skipping 27 matching lines...) Expand all
67 num_exit_requests_++; 95 num_exit_requests_++;
68 } 96 }
69 97
70 keyboard::KeyboardUI* TestShellDelegate::CreateKeyboardUI() { 98 keyboard::KeyboardUI* TestShellDelegate::CreateKeyboardUI() {
71 return new TestKeyboardUI; 99 return new TestKeyboardUI;
72 } 100 }
73 101
74 void TestShellDelegate::OpenUrlFromArc(const GURL& url) {} 102 void TestShellDelegate::OpenUrlFromArc(const GURL& url) {}
75 103
76 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) { 104 ShelfDelegate* TestShellDelegate::CreateShelfDelegate(ShelfModel* model) {
105 // Create a separate shelf initializer that mimics ChromeLauncherController.
106 shelf_initializer_ = base::MakeUnique<ShelfInitializer>();
77 return new TestShelfDelegate(); 107 return new TestShelfDelegate();
78 } 108 }
79 109
80 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() { 110 SystemTrayDelegate* TestShellDelegate::CreateSystemTrayDelegate() {
81 return new TestSystemTrayDelegate; 111 return new TestSystemTrayDelegate;
82 } 112 }
83 113
84 std::unique_ptr<WallpaperDelegate> 114 std::unique_ptr<WallpaperDelegate>
85 TestShellDelegate::CreateWallpaperDelegate() { 115 TestShellDelegate::CreateWallpaperDelegate() {
86 return base::MakeUnique<TestWallpaperDelegate>(); 116 return base::MakeUnique<TestWallpaperDelegate>();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void TestShellDelegate::SetTouchscreenEnabledInPrefs(bool enabled, 154 void TestShellDelegate::SetTouchscreenEnabledInPrefs(bool enabled,
125 bool use_local_state) { 155 bool use_local_state) {
126 if (use_local_state) 156 if (use_local_state)
127 touchscreen_enabled_in_local_pref_ = enabled; 157 touchscreen_enabled_in_local_pref_ = enabled;
128 } 158 }
129 159
130 void TestShellDelegate::UpdateTouchscreenStatusFromPrefs() {} 160 void TestShellDelegate::UpdateTouchscreenStatusFromPrefs() {}
131 161
132 } // namespace test 162 } // namespace test
133 } // namespace ash 163 } // namespace ash
OLDNEW
« 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