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

Unified Diff: ui/views/view_unittest.cc

Issue 129863002: Makes View::focusable() return last value supplied to SetFocusable() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix views_examples Created 6 years, 11 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/view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/view_unittest.cc
diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc
index af3eb6551f9e4a045c00d9c3e181c7565d392509..7786a4786aab8b2df0921bcebabb48e8e62e8782 100644
--- a/ui/views/view_unittest.cc
+++ b/ui/views/view_unittest.cc
@@ -231,6 +231,8 @@ class TestView : public View {
views::View::Blur();
}
+ bool focusable() const { return View::focusable(); }
+
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
@@ -3572,4 +3574,20 @@ TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) {
#endif // USE_AURA
+TEST_F(ViewTest, FocusableAssertions) {
+ // View subclasses may change insets based on whether they are focusable,
+ // which effects the preferred size. To avoid preferred size changing around
+ // these Views need to key off the last value set to SetFocusable(), not
+ // whether the View is focusable right now. For this reason it's important
+ // that focusable() return the last value passed to SetFocusable and not
+ // whether the View is focusable right now.
+ TestView view;
+ view.SetFocusable(true);
+ EXPECT_TRUE(view.focusable());
+ view.SetEnabled(false);
+ EXPECT_TRUE(view.focusable());
+ view.SetFocusable(false);
+ EXPECT_FALSE(view.focusable());
+}
+
} // namespace views
« no previous file with comments | « ui/views/view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698