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

Unified Diff: ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc

Issue 2746813002: Hide AXPlatformNode on ChromeOS. (Closed)
Patch Set: fix stub Created 3 years, 9 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
Index: ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
diff --git a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 3a5287614e9d52581935917881aefacfd7ccc0a3..ecd7ca02f414c6c024fb22276c1ed48dd2068a03 100644
--- a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -12,12 +12,16 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.h"
+#include "ui/base/ui_features.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
-#include "ui/views/accessibility/native_view_accessibility.h"
#include "ui/views/test/test_views.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget.h"
+#if BUILDFLAG(HAS_PLATFORM_ACCESSIBILITY)
+#include "ui/views/accessibility/native_view_accessibility.h"
+#endif
+
using base::ASCIIToUTF16;
namespace views {
@@ -139,6 +143,8 @@ TEST_F(TabbedPaneTest, ArrowKeyBindings) {
EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
}
+#if BUILDFLAG(HAS_PLATFORM_ACCESSIBILITY)
dmazzoni 2017/03/20 15:44:06 Hmmm, I understand why you did this, but the Views
tapted 2017/03/21 02:27:49 Done.
+
// Use TabbedPane::HandleAccessibleAction() to select tabs and make sure their
// a11y information is correct.
TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) {
@@ -156,10 +162,16 @@ TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) {
// Check the first tab is selected.
EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
+ // Usually these are owned by a View. Put them on the stack so they can be
+ // accessed for testing.
+ std::unique_ptr<NativeViewAccessibilityBase> nva[kNumTabs];
+ NativeViewAccessibility* pnva[kNumTabs];
+
// Check the a11y information for each tab.
for (int i = 0; i < kNumTabs; ++i) {
- ui::AXNodeData data =
- NativeViewAccessibility::Create(GetTabAt(i))->GetData();
+ nva[i] = NativeViewAccessibilityBase::Create(GetTabAt(i));
+ pnva[i] = static_cast<NativeViewAccessibility*>(nva[i].get());
+ ui::AXNodeData data = pnva[i]->GetData();
dmazzoni 2017/03/20 15:44:06 How about GetTabAt(i)->GetAccessibleNodeData() ins
tapted 2017/03/21 02:27:49 Done.
SCOPED_TRACE(testing::Message() << "Tab at index: " << i);
EXPECT_EQ(ui::AX_ROLE_TAB, data.role);
EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME));
@@ -171,22 +183,23 @@ TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) {
action.action = ui::AX_ACTION_SET_SELECTION;
// Select the first tab.
- NativeViewAccessibility::Create(GetTabAt(0))
- ->AccessibilityPerformAction(action);
+ pnva[0]->AccessibilityPerformAction(action);
dmazzoni 2017/03/20 15:44:06 Same here: GetTabAt(i)->HandleAccessibleAction. If
tapted 2017/03/21 02:27:49 Done.
EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
// Select the second tab.
- std::unique_ptr<NativeViewAccessibility> nva =
- NativeViewAccessibility::Create(GetTabAt(1));
- nva->AccessibilityPerformAction(action);
+ pnva[1]->AccessibilityPerformAction(action);
EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex());
// Select the second tab again.
- nva->AccessibilityPerformAction(action);
+ pnva[1]->AccessibilityPerformAction(action);
EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex());
- nva.reset();
+ for (auto& ptr : nva)
+ ptr.reset();
+
widget->CloseNow();
}
+#endif // HAS_PLATFORM_ACCESSIBILITY
+
} // namespace test
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698