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

Side by Side Diff: ash/wm/screen_pinning_controller_unittest.cc

Issue 2780943002: Enables ScreenPinningController for mash/mus (Closed)
Patch Set: local 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/wm/screen_pinning_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/wm/screen_pinning_controller.h" 5 #include "ash/wm/screen_pinning_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/wm/window_state.h" 10 #include "ash/common/wm/window_state.h"
11 #include "ash/common/wm/wm_event.h" 11 #include "ash/common/wm/wm_event.h"
12 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
13 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/wm/screen_pinning_controller.h"
16 #include "ash/wm/window_util.h" 17 #include "ash/wm/window_util.h"
17 #include "base/stl_util.h" 18 #include "base/stl_util.h"
18 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
19 20
20 namespace ash { 21 namespace ash {
21 namespace { 22 namespace {
22 23
23 int FindIndex(const std::vector<aura::Window*>& windows, 24 int FindIndex(const std::vector<aura::Window*>& windows,
24 const aura::Window* target) { 25 const aura::Window* target) {
25 auto iter = std::find(windows.begin(), windows.end(), target); 26 auto iter = std::find(windows.begin(), windows.end(), target);
26 return iter != windows.end() ? iter - windows.begin() : -1; 27 return iter != windows.end() ? iter - windows.begin() : -1;
27 } 28 }
28 29
29 } // namespace 30 } // namespace
30 31
31 using ScreenPinningControllerTest = test::AshTestBase; 32 using ScreenPinningControllerTest = test::AshTestBase;
32 33
33 TEST_F(ScreenPinningControllerTest, IsPinned) { 34 TEST_F(ScreenPinningControllerTest, IsPinned) {
34 aura::Window* w1 = CreateTestWindowInShellWithId(0); 35 aura::Window* w1 = CreateTestWindowInShellWithId(0);
35 wm::ActivateWindow(w1); 36 wm::ActivateWindow(w1);
36 37
37 wm::PinWindow(w1, /* trusted */ false); 38 wm::PinWindow(w1, /* trusted */ false);
38 EXPECT_TRUE(WmShell::Get()->IsPinned()); 39 EXPECT_TRUE(Shell::Get()->screen_pinning_controller()->IsPinned());
39 } 40 }
40 41
41 TEST_F(ScreenPinningControllerTest, OnlyOnePinnedWindow) { 42 TEST_F(ScreenPinningControllerTest, OnlyOnePinnedWindow) {
42 aura::Window* w1 = CreateTestWindowInShellWithId(0); 43 aura::Window* w1 = CreateTestWindowInShellWithId(0);
43 aura::Window* w2 = CreateTestWindowInShellWithId(1); 44 aura::Window* w2 = CreateTestWindowInShellWithId(1);
44 wm::ActivateWindow(w1); 45 wm::ActivateWindow(w1);
45 46
46 wm::PinWindow(w1, /* trusted */ false); 47 wm::PinWindow(w1, /* trusted */ false);
47 EXPECT_TRUE(WmWindow::Get(w1)->GetWindowState()->IsPinned()); 48 EXPECT_TRUE(WmWindow::Get(w1)->GetWindowState()->IsPinned());
48 EXPECT_FALSE(WmWindow::Get(w2)->GetWindowState()->IsPinned()); 49 EXPECT_FALSE(WmWindow::Get(w2)->GetWindowState()->IsPinned());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 EXPECT_NE(-1, index2); 152 EXPECT_NE(-1, index2);
152 EXPECT_GT(index2, index1); 153 EXPECT_GT(index2, index1);
153 } 154 }
154 } 155 }
155 156
156 TEST_F(ScreenPinningControllerTest, TrustedPinnedWithAccelerator) { 157 TEST_F(ScreenPinningControllerTest, TrustedPinnedWithAccelerator) {
157 aura::Window* w1 = CreateTestWindowInShellWithId(0); 158 aura::Window* w1 = CreateTestWindowInShellWithId(0);
158 wm::ActivateWindow(w1); 159 wm::ActivateWindow(w1);
159 160
160 wm::PinWindow(w1, /* trusted */ true); 161 wm::PinWindow(w1, /* trusted */ true);
161 EXPECT_TRUE(WmShell::Get()->IsPinned()); 162 EXPECT_TRUE(Shell::Get()->screen_pinning_controller()->IsPinned());
162 163
163 Shell::Get()->accelerator_controller()->PerformActionIfEnabled(UNPIN); 164 Shell::Get()->accelerator_controller()->PerformActionIfEnabled(UNPIN);
164 // The UNPIN accelerator key is disabled for trusted pinned and the window 165 // The UNPIN accelerator key is disabled for trusted pinned and the window
165 // must be still pinned. 166 // must be still pinned.
166 EXPECT_TRUE(WmShell::Get()->IsPinned()); 167 EXPECT_TRUE(Shell::Get()->screen_pinning_controller()->IsPinned());
167 } 168 }
168 169
169 } // namespace ash 170 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/screen_pinning_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698