OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
| 6 |
| 7 #include <memory> |
| 8 |
5 #include "base/macros.h" | 9 #include "base/macros.h" |
6 #include "base/memory/scoped_ptr.h" | |
7 #include "content/browser/accessibility/browser_accessibility.h" | 10 #include "content/browser/accessibility/browser_accessibility.h" |
8 #include "content/browser/accessibility/browser_accessibility_manager.h" | 11 #include "content/browser/accessibility/browser_accessibility_manager.h" |
9 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
11 | 13 |
12 namespace content { | 14 namespace content { |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 class TestBrowserAccessibilityManager : public BrowserAccessibilityManager { | 18 class TestBrowserAccessibilityManager : public BrowserAccessibilityManager { |
17 public: | 19 public: |
18 TestBrowserAccessibilityManager( | 20 TestBrowserAccessibilityManager( |
19 const ui::AXTreeUpdate& initial_tree) | 21 const ui::AXTreeUpdate& initial_tree) |
(...skipping 11 matching lines...) Expand all Loading... |
31 #define MAYBE_OneShotAccessibilityTreeSearchTest OneShotAccessibilityTreeSearchT
est | 33 #define MAYBE_OneShotAccessibilityTreeSearchTest OneShotAccessibilityTreeSearchT
est |
32 #endif | 34 #endif |
33 class MAYBE_OneShotAccessibilityTreeSearchTest : public testing::Test { | 35 class MAYBE_OneShotAccessibilityTreeSearchTest : public testing::Test { |
34 public: | 36 public: |
35 MAYBE_OneShotAccessibilityTreeSearchTest() {} | 37 MAYBE_OneShotAccessibilityTreeSearchTest() {} |
36 ~MAYBE_OneShotAccessibilityTreeSearchTest() override {} | 38 ~MAYBE_OneShotAccessibilityTreeSearchTest() override {} |
37 | 39 |
38 protected: | 40 protected: |
39 void SetUp() override; | 41 void SetUp() override; |
40 | 42 |
41 scoped_ptr<BrowserAccessibilityManager> tree_; | 43 std::unique_ptr<BrowserAccessibilityManager> tree_; |
42 | 44 |
43 private: | 45 private: |
44 DISALLOW_COPY_AND_ASSIGN(MAYBE_OneShotAccessibilityTreeSearchTest); | 46 DISALLOW_COPY_AND_ASSIGN(MAYBE_OneShotAccessibilityTreeSearchTest); |
45 }; | 47 }; |
46 | 48 |
47 void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { | 49 void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { |
48 ui::AXNodeData root; | 50 ui::AXNodeData root; |
49 root.id = 1; | 51 root.id = 1; |
50 root.SetName("Document"); | 52 root.SetName("Document"); |
51 root.role = ui::AX_ROLE_ROOT_WEB_AREA; | 53 root.role = ui::AX_ROLE_ROOT_WEB_AREA; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 search.AddPredicate([](BrowserAccessibility* start, | 218 search.AddPredicate([](BrowserAccessibility* start, |
217 BrowserAccessibility* current) { | 219 BrowserAccessibility* current) { |
218 return (current->GetId() % 2 == 1); | 220 return (current->GetId() % 2 == 1); |
219 }); | 221 }); |
220 ASSERT_EQ(2U, search.CountMatches()); | 222 ASSERT_EQ(2U, search.CountMatches()); |
221 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); | 223 EXPECT_EQ(3, search.GetMatchAtIndex(0)->GetId()); |
222 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); | 224 EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); |
223 } | 225 } |
224 | 226 |
225 } // namespace content | 227 } // namespace content |
OLD | NEW |