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

Side by Side Diff: ui/views/accessibility/native_view_accessibility_unittest.cc

Issue 2860883003: A11y: Add/refactor methods for manipulating bitfields on AXNodeData. (Closed)
Patch Set: Delete AXNodeData::Init() and clear bitfields in AXNodeData() instead. Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "ui/accessibility/ax_node_data.h" 7 #include "ui/accessibility/ax_node_data.h"
8 #include "ui/gfx/geometry/rect_conversions.h" 8 #include "ui/gfx/geometry/rect_conversions.h"
9 #include "ui/views/accessibility/ax_aura_obj_cache.h" 9 #include "ui/views/accessibility/ax_aura_obj_cache.h"
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 EXPECT_EQ(label_->GetNativeViewAccessible(), 104 EXPECT_EQ(label_->GetNativeViewAccessible(),
105 button_accessibility()->ChildAtIndex(0)); 105 button_accessibility()->ChildAtIndex(0));
106 EXPECT_EQ(button_->GetNativeViewAccessible(), 106 EXPECT_EQ(button_->GetNativeViewAccessible(),
107 label_accessibility()->GetParent()); 107 label_accessibility()->GetParent());
108 } 108 }
109 109
110 // Verify Views with invisible ancestors have AX_STATE_INVISIBLE. 110 // Verify Views with invisible ancestors have AX_STATE_INVISIBLE.
111 TEST_F(NativeViewAccessibilityTest, InvisibleViews) { 111 TEST_F(NativeViewAccessibilityTest, InvisibleViews) {
112 EXPECT_TRUE(widget_->IsVisible()); 112 EXPECT_TRUE(widget_->IsVisible());
113 EXPECT_FALSE( 113 EXPECT_FALSE(
114 button_accessibility()->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); 114 button_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE));
115 EXPECT_FALSE( 115 EXPECT_FALSE(
116 label_accessibility()->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); 116 label_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE));
117 button_->SetVisible(false); 117 button_->SetVisible(false);
118 EXPECT_TRUE( 118 EXPECT_TRUE(
119 button_accessibility()->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); 119 button_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE));
120 EXPECT_TRUE( 120 EXPECT_TRUE(
121 label_accessibility()->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE)); 121 label_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE));
122 } 122 }
123 123
124 TEST_F(NativeViewAccessibilityTest, WritableFocus) { 124 TEST_F(NativeViewAccessibilityTest, WritableFocus) {
125 // Make |button_| focusable, and focus/unfocus it via NativeViewAccessibility. 125 // Make |button_| focusable, and focus/unfocus it via NativeViewAccessibility.
126 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS); 126 button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
127 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView()); 127 EXPECT_EQ(nullptr, button_->GetFocusManager()->GetFocusedView());
128 EXPECT_EQ(nullptr, button_accessibility()->GetFocus()); 128 EXPECT_EQ(nullptr, button_accessibility()->GetFocus());
129 EXPECT_TRUE(SetFocused(button_accessibility(), true)); 129 EXPECT_TRUE(SetFocused(button_accessibility(), true));
130 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView()); 130 EXPECT_EQ(button_, button_->GetFocusManager()->GetFocusedView());
131 EXPECT_EQ(button_->GetNativeViewAccessible(), 131 EXPECT_EQ(button_->GetNativeViewAccessible(),
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // During the destruction of parent, OnBlur will be called and change the 234 // During the destruction of parent, OnBlur will be called and change the
235 // visibility to false. 235 // visibility to false.
236 parent->SetVisible(true); 236 parent->SetVisible(true);
237 AXAuraObjCache* ax = AXAuraObjCache::GetInstance(); 237 AXAuraObjCache* ax = AXAuraObjCache::GetInstance();
238 ax->GetOrCreate(widget.get()); 238 ax->GetOrCreate(widget.get());
239 } 239 }
240 #endif 240 #endif
241 241
242 } // namespace test 242 } // namespace test
243 } // namespace views 243 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698