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

Unified Diff: ui/views/corewm/focus_controller_unittest.cc

Issue 14298013: Check focusability in WindowFocusedFromInputEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update FocusController tests Created 7 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 | « ui/views/corewm/focus_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/focus_controller_unittest.cc
diff --git a/ui/views/corewm/focus_controller_unittest.cc b/ui/views/corewm/focus_controller_unittest.cc
index 6eaf81d9227dd7ebc1c43b96313d0c8ac2803f1e..335bb6c4b6c684054c42d772039d037eb3bd2409 100644
--- a/ui/views/corewm/focus_controller_unittest.cc
+++ b/ui/views/corewm/focus_controller_unittest.cc
@@ -298,6 +298,9 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase {
virtual void ActivateWindowDirect(aura::Window* window) = 0;
virtual void DeactivateWindowDirect(aura::Window* window) = 0;
+ // Input events do not change focus if the window can not be focused.
+ virtual bool IsInputEvent() = 0;
+
void FocusWindowById(int id) {
aura::Window* window = root_window()->GetChildById(id);
DCHECK(window);
@@ -436,7 +439,10 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase {
test_focus_rules()->set_focus_restriction(root_window()->GetChildById(211));
FocusWindowById(12);
- EXPECT_EQ(211, GetFocusedWindowId());
+ // Input events leave focus unchanged; direct API calls will change focus
+ // to the restricted window.
+ int focused_window = IsInputEvent() ? 11 : 211;
+ EXPECT_EQ(focused_window, GetFocusedWindowId());
test_focus_rules()->set_focus_restriction(NULL);
FocusWindowById(12);
@@ -451,9 +457,11 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase {
test_focus_rules()->set_focus_restriction(w3);
ActivateWindowById(2);
- // FocusRules restricts focus and activation to 3.
- EXPECT_EQ(3, GetActiveWindowId());
- EXPECT_EQ(3, GetFocusedWindowId());
+ // Input events leave activation unchanged; direct API calls will activate
+ // the restricted window.
+ int active_window = IsInputEvent() ? 1 : 3;
+ EXPECT_EQ(active_window, GetActiveWindowId());
+ EXPECT_EQ(active_window, GetFocusedWindowId());
test_focus_rules()->set_focus_restriction(NULL);
ActivateWindowById(2);
@@ -573,6 +581,7 @@ class FocusControllerApiTest : public FocusControllerDirectTestBase {
virtual void DeactivateWindowDirect(aura::Window* window) OVERRIDE {
DeactivateWindow(window);
}
+ virtual bool IsInputEvent() OVERRIDE { return false; }
DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest);
};
@@ -598,6 +607,7 @@ class FocusControllerMouseEventTest : public FocusControllerDirectTestBase {
aura::test::EventGenerator generator(root_window(), next_activatable);
generator.ClickLeftButton();
}
+ virtual bool IsInputEvent() OVERRIDE { return true; }
DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest);
};
@@ -622,6 +632,7 @@ class FocusControllerGestureEventTest : public FocusControllerDirectTestBase {
aura::test::EventGenerator generator(root_window(), next_activatable);
generator.GestureTapAt(window->bounds().CenterPoint());
}
+ virtual bool IsInputEvent() OVERRIDE { return true; }
DISALLOW_COPY_AND_ASSIGN(FocusControllerGestureEventTest);
};
« no previous file with comments | « ui/views/corewm/focus_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698