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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <map> 5 #include <map>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // Exposed as public for testing. 225 // Exposed as public for testing.
226 void DoFocus() { 226 void DoFocus() {
227 views::View::Focus(); 227 views::View::Focus();
228 } 228 }
229 229
230 void DoBlur() { 230 void DoBlur() {
231 views::View::Blur(); 231 views::View::Blur();
232 } 232 }
233 233
234 bool focusable() const { return View::focusable(); }
235
234 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 236 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
235 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 237 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
236 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; 238 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
237 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; 239 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
238 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; 240 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
239 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 241 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
240 242
241 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; 243 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
242 // Ignores GestureEvent by default. 244 // Ignores GestureEvent by default.
243 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 245 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
(...skipping 3321 matching lines...) Expand 10 before | Expand all | Expand 10 after
3565 // for |v1| and |v2|. 3567 // for |v1| and |v2|.
3566 const std::vector<ui::Layer*>& child_layers_post = root_layer->children(); 3568 const std::vector<ui::Layer*>& child_layers_post = root_layer->children();
3567 ASSERT_EQ(3u, child_layers_post.size()); 3569 ASSERT_EQ(3u, child_layers_post.size());
3568 EXPECT_EQ(v1->layer(), child_layers_post[0]); 3570 EXPECT_EQ(v1->layer(), child_layers_post[0]);
3569 EXPECT_EQ(v2->layer(), child_layers_post[1]); 3571 EXPECT_EQ(v2->layer(), child_layers_post[1]);
3570 EXPECT_EQ(v1_old_layer, child_layers_post[2]); 3572 EXPECT_EQ(v1_old_layer, child_layers_post[2]);
3571 } 3573 }
3572 3574
3573 #endif // USE_AURA 3575 #endif // USE_AURA
3574 3576
3577 TEST_F(ViewTest, FocusableAssertions) {
3578 // View subclasses may change insets based on whether they are focusable,
3579 // which effects the preferred size. To avoid preferred size changing around
3580 // these Views need to key off the last value set to SetFocusable(), not
3581 // whether the View is focusable right now. For this reason it's important
3582 // that focusable() return the last value passed to SetFocusable and not
3583 // whether the View is focusable right now.
3584 TestView view;
3585 view.SetFocusable(true);
3586 EXPECT_TRUE(view.focusable());
3587 view.SetEnabled(false);
3588 EXPECT_TRUE(view.focusable());
3589 view.SetFocusable(false);
3590 EXPECT_FALSE(view.focusable());
3591 }
3592
3575 } // namespace views 3593 } // namespace views
OLDNEW
« 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