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

Side by Side Diff: ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc

Issue 2119413004: a11y: Exclude children of nested keyboard accessible controls from a11y tree. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of 2704263002. Created 3 years, 10 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 (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 "ui/views/controls/tabbed_pane/tabbed_pane.h" 5 #include "ui/views/controls/tabbed_pane/tabbed_pane.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 constexpr int kNumTabs = 3; 152 constexpr int kNumTabs = 3;
153 for (int i = 0; i < kNumTabs; ++i) { 153 for (int i = 0; i < kNumTabs; ++i) {
154 tabbed_pane_->AddTab(DefaultTabTitle(), new View()); 154 tabbed_pane_->AddTab(DefaultTabTitle(), new View());
155 } 155 }
156 // Check the first tab is selected. 156 // Check the first tab is selected.
157 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); 157 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
158 158
159 // Check the a11y information for each tab. 159 // Check the a11y information for each tab.
160 for (int i = 0; i < kNumTabs; ++i) { 160 for (int i = 0; i < kNumTabs; ++i) {
161 NativeViewAccessibility* nva = NativeViewAccessibility::Create(GetTabAt(i)); 161 ui::AXNodeData data =
tapted 2017/02/21 06:01:12 same here - can these just be unique_ptr?
Patti Lor 2017/02/27 05:31:04 Done.
162 ui::AXNodeData data = nva->GetData(); 162 NativeViewAccessibility::GetForView(GetTabAt(i))->GetData();
163 SCOPED_TRACE(testing::Message() << "Tab at index: " << i); 163 SCOPED_TRACE(testing::Message() << "Tab at index: " << i);
164 EXPECT_EQ(ui::AX_ROLE_TAB, data.role); 164 EXPECT_EQ(ui::AX_ROLE_TAB, data.role);
165 EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME)); 165 EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME));
166 EXPECT_TRUE(data.HasStateFlag(ui::AX_STATE_SELECTABLE)); 166 EXPECT_TRUE(data.HasStateFlag(ui::AX_STATE_SELECTABLE));
167 EXPECT_EQ(i == 0, data.HasStateFlag(ui::AX_STATE_SELECTED)); 167 EXPECT_EQ(i == 0, data.HasStateFlag(ui::AX_STATE_SELECTED));
168 nva->Destroy();
169 } 168 }
170 169
171 ui::AXActionData action; 170 ui::AXActionData action;
172 action.action = ui::AX_ACTION_SET_SELECTION; 171 action.action = ui::AX_ACTION_SET_SELECTION;
173 // Select the first tab. 172 // Select the first tab.
174 NativeViewAccessibility* nva = NativeViewAccessibility::Create(GetTabAt(0)); 173
175 nva->AccessibilityPerformAction(action); 174 NativeViewAccessibility::GetForView(GetTabAt(0))
175 ->AccessibilityPerformAction(action);
176 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); 176 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
177 nva->Destroy();
178 177
179 // Select the second tab. 178 // Select the second tab.
180 nva = NativeViewAccessibility::Create(GetTabAt(1)); 179 NativeViewAccessibility* nva =
180 NativeViewAccessibility::GetForView(GetTabAt(1));
181 nva->AccessibilityPerformAction(action); 181 nva->AccessibilityPerformAction(action);
182 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); 182 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex());
183 // Select the second tab again. 183 // Select the second tab again.
184 nva->AccessibilityPerformAction(action); 184 nva->AccessibilityPerformAction(action);
185 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); 185 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex());
186 nva->Destroy();
187 186
188 widget->CloseNow(); 187 widget->CloseNow();
189 } 188 }
190 189
191 } // namespace test 190 } // namespace test
192 } // namespace views 191 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698