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

Unified Diff: ash/wm/ash_focus_rules_unittest.cc

Issue 2734933004: ash: Use SessionController instead of SessionStateDelegate (Closed)
Patch Set: rebase to get WorkspaceLayoutManagerSoloTest change Created 3 years, 9 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/wm/always_on_top_controller_unittest.cc ('k') | ash/wm/event_client_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/ash_focus_rules_unittest.cc
diff --git a/ash/wm/ash_focus_rules_unittest.cc b/ash/wm/ash_focus_rules_unittest.cc
index faabf2d7e3a75e5f61a420401dd8f289577a8856..8e847febeddf802a6cafeb104aeb6b96fcd11683 100644
--- a/ash/wm/ash_focus_rules_unittest.cc
+++ b/ash/wm/ash_focus_rules_unittest.cc
@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/common/session/session_state_delegate.h"
-#include "ash/common/test/test_session_state_delegate.h"
+#include "ash/common/session/session_controller.h"
+#include "ash/common/test/test_session_controller_client.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_shell.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h"
-#include "ash/test/test_shell_delegate.h"
#include "ash/wm/lock_state_controller.h"
#include "ash/wm/window_state_aura.h"
#include "ash/wm/window_util.h"
+#include "base/memory/ptr_util.h"
#include "services/ui/public/interfaces/window_manager_constants.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_parenting_client.h"
@@ -26,21 +26,26 @@ namespace test {
namespace {
-// Defines a |SessionStateDelegate| that is used to create and destroy the
+// Defines a |SessionControllerClient| that is used to create and destroy the
// test lock screen widget.
-class LockScreenSessionStateDelegate : public TestSessionStateDelegate {
+class LockScreenSessionControllerClient : public TestSessionControllerClient {
public:
- LockScreenSessionStateDelegate() {}
- ~LockScreenSessionStateDelegate() override {}
+ explicit LockScreenSessionControllerClient(SessionController* controller)
+ : TestSessionControllerClient(controller) {
+ InitializeAndBind();
+ CreatePredefinedUserSessions(1);
+ }
+ ~LockScreenSessionControllerClient() override {}
- void LockScreen() override {
- TestSessionStateDelegate::LockScreen();
+ // TestSessionControllerClient:
+ void RequestLockScreen() override {
+ TestSessionControllerClient::RequestLockScreen();
CreateLockScreen();
Shell::GetInstance()->UpdateShelfVisibility();
}
void UnlockScreen() override {
- TestSessionStateDelegate::UnlockScreen();
+ TestSessionControllerClient::UnlockScreen();
if (lock_screen_widget_.get()) {
lock_screen_widget_->Close();
lock_screen_widget_.reset(nullptr);
@@ -73,24 +78,7 @@ class LockScreenSessionStateDelegate : public TestSessionStateDelegate {
std::unique_ptr<views::Widget> lock_screen_widget_;
- DISALLOW_COPY_AND_ASSIGN(LockScreenSessionStateDelegate);
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Defines a |ShellDelegate| that is used to construct our lock screen
-// |SessionStateDelegate|.
-class LockScreenShellDelegate : public test::TestShellDelegate {
- public:
- LockScreenShellDelegate() {}
- ~LockScreenShellDelegate() override {}
-
- TestSessionStateDelegate* CreateSessionStateDelegate() override {
- return new LockScreenSessionStateDelegate();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LockScreenShellDelegate);
+ DISALLOW_COPY_AND_ASSIGN(LockScreenSessionControllerClient);
};
////////////////////////////////////////////////////////////////////////////////
@@ -103,8 +91,10 @@ class LockScreenAshFocusRulesTest : public AshTestBase {
~LockScreenAshFocusRulesTest() override {}
void SetUp() override {
- ash_test_helper()->set_test_shell_delegate(new LockScreenShellDelegate);
AshTestBase::SetUp();
+ ash_test_helper()->set_test_session_controller_client(
+ base::MakeUnique<LockScreenSessionControllerClient>(
+ WmShell::Get()->session_controller()));
}
void TearDown() override { AshTestBase::TearDown(); }
@@ -140,6 +130,8 @@ class LockScreenAshFocusRulesTest : public AshTestBase {
return window;
}
+ std::unique_ptr<LockScreenSessionControllerClient> session_controller_client_;
+
DISALLOW_COPY_AND_ASSIGN(LockScreenAshFocusRulesTest);
};
@@ -171,7 +163,7 @@ TEST_F(LockScreenAshFocusRulesTest, RegainFocusAfterUnlock) {
BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
- EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
+ EXPECT_TRUE(WmShell::Get()->session_controller()->IsScreenLocked());
EXPECT_FALSE(normal_window->HasFocus());
EXPECT_FALSE(always_on_top_window->HasFocus());
EXPECT_FALSE(normal_window_state->IsMinimized());
@@ -181,7 +173,7 @@ TEST_F(LockScreenAshFocusRulesTest, RegainFocusAfterUnlock) {
UnblockUserSession();
- EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
+ EXPECT_FALSE(WmShell::Get()->session_controller()->IsScreenLocked());
EXPECT_FALSE(normal_window_state->IsMinimized());
EXPECT_FALSE(always_on_top_window_state->IsMinimized());
EXPECT_TRUE(normal_window_state->CanActivate());
@@ -194,7 +186,7 @@ TEST_F(LockScreenAshFocusRulesTest, RegainFocusAfterUnlock) {
// view doesn't get focused if the widget shows behind the lock screen.
TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) {
BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
- EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
+ EXPECT_TRUE(WmShell::Get()->session_controller()->IsScreenLocked());
views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext());
EXPECT_FALSE(delegate.view()->HasFocus());
@@ -203,7 +195,7 @@ TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) {
EXPECT_FALSE(delegate.view()->HasFocus());
UnblockUserSession();
- EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked());
+ EXPECT_FALSE(WmShell::Get()->session_controller()->IsScreenLocked());
EXPECT_TRUE(delegate.GetWidget()->IsActive());
EXPECT_TRUE(delegate.view()->HasFocus());
}
« no previous file with comments | « ash/wm/always_on_top_controller_unittest.cc ('k') | ash/wm/event_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698