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

Unified Diff: ash/wm/ash_focus_rules_unittest.cc

Issue 1753473003: A window should not get activated or get input focus if it's behind the lock screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modify the test to use NativeWidgetAura when initializing widget. Created 4 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 | « no previous file | ui/views/test/widget_test.h » ('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 fe06fa47353ea0c704f7bbb0f03ba72b6159c6e9..542f10f29b163950cc3b9e4e918a609d71635671 100644
--- a/ash/wm/ash_focus_rules_unittest.cc
+++ b/ash/wm/ash_focus_rules_unittest.cc
@@ -14,6 +14,7 @@
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
+#include "ui/views/test/widget_test.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
@@ -186,5 +187,23 @@ TEST_F(LockScreenAshFocusRulesTest, RegainFocusAfterUnlock) {
EXPECT_TRUE(normal_window->HasFocus());
}
+// Tests that if a widget has a view which should be initially focused, this
+// view doesn't get focused if the widget shows behind the lock screen.
+TEST_F(LockScreenAshFocusRulesTest, PreventFocusChangeWithLockScreenPresent) {
+ BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
+ EXPECT_TRUE(shell()->session_state_delegate()->IsScreenLocked());
+
+ views::test::TestInitialFocusWidgetDelegate delegate(CurrentContext());
+ EXPECT_FALSE(delegate.view()->HasFocus());
+ delegate.GetWidget()->Show();
+ EXPECT_FALSE(delegate.GetWidget()->IsActive());
+ EXPECT_FALSE(delegate.view()->HasFocus());
+
+ UnblockUserSession();
+ EXPECT_FALSE(shell()->session_state_delegate()->IsScreenLocked());
+ EXPECT_TRUE(delegate.GetWidget()->IsActive());
+ EXPECT_TRUE(delegate.view()->HasFocus());
+}
+
} // namespace test
} // namespace ash
« no previous file with comments | « no previous file | ui/views/test/widget_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698