| OLD | NEW |
| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 ui::AXNodeData data; | 161 ui::AXNodeData data; |
| 162 | |
| 163 // AXViewObjWrapper::Serialize() and NativeViewAccessibilityBase::GetData() | |
| 164 // are normally responsible for clearing the state from the default | |
| 165 // AXNodeData constructor. Do the same here. | |
| 166 data.state = 0; | |
| 167 | |
| 168 GetTabAt(i)->GetAccessibleNodeData(&data); | 162 GetTabAt(i)->GetAccessibleNodeData(&data); |
| 169 SCOPED_TRACE(testing::Message() << "Tab at index: " << i); | 163 SCOPED_TRACE(testing::Message() << "Tab at index: " << i); |
| 170 EXPECT_EQ(ui::AX_ROLE_TAB, data.role); | 164 EXPECT_EQ(ui::AX_ROLE_TAB, data.role); |
| 171 EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME)); | 165 EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME)); |
| 172 EXPECT_TRUE(data.HasStateFlag(ui::AX_STATE_SELECTABLE)); | 166 EXPECT_TRUE(data.HasState(ui::AX_STATE_SELECTABLE)); |
| 173 EXPECT_EQ(i == 0, data.HasStateFlag(ui::AX_STATE_SELECTED)); | 167 EXPECT_EQ(i == 0, data.HasState(ui::AX_STATE_SELECTED)); |
| 174 } | 168 } |
| 175 | 169 |
| 176 ui::AXActionData action; | 170 ui::AXActionData action; |
| 177 action.action = ui::AX_ACTION_SET_SELECTION; | 171 action.action = ui::AX_ACTION_SET_SELECTION; |
| 178 // Select the first tab. | 172 // Select the first tab. |
| 179 | 173 |
| 180 GetTabAt(0)->HandleAccessibleAction(action); | 174 GetTabAt(0)->HandleAccessibleAction(action); |
| 181 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); | 175 EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex()); |
| 182 | 176 |
| 183 // Select the second tab. | 177 // Select the second tab. |
| 184 GetTabAt(1)->HandleAccessibleAction(action); | 178 GetTabAt(1)->HandleAccessibleAction(action); |
| 185 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); | 179 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); |
| 186 // Select the second tab again. | 180 // Select the second tab again. |
| 187 GetTabAt(1)->HandleAccessibleAction(action); | 181 GetTabAt(1)->HandleAccessibleAction(action); |
| 188 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); | 182 EXPECT_EQ(1, tabbed_pane_->GetSelectedTabIndex()); |
| 189 | 183 |
| 190 widget->CloseNow(); | 184 widget->CloseNow(); |
| 191 } | 185 } |
| 192 | 186 |
| 193 } // namespace test | 187 } // namespace test |
| 194 } // namespace views | 188 } // namespace views |
| OLD | NEW |