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

Side by Side Diff: ui/accessibility/ax_generated_tree_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_context.h ('k') | ui/accessibility/ax_node_data.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory>
6
5 #include "base/macros.h" 7 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/accessibility/ax_node.h" 10 #include "ui/accessibility/ax_node.h"
10 #include "ui/accessibility/ax_serializable_tree.h" 11 #include "ui/accessibility/ax_serializable_tree.h"
11 #include "ui/accessibility/ax_tree.h" 12 #include "ui/accessibility/ax_tree.h"
12 #include "ui/accessibility/ax_tree_serializer.h" 13 #include "ui/accessibility/ax_tree_serializer.h"
13 #include "ui/accessibility/tree_generator.h" 14 #include "ui/accessibility/tree_generator.h"
14 15
15 namespace ui { 16 namespace ui {
16 namespace { 17 namespace {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 int tree_size = tree1.size(); 147 int tree_size = tree1.size();
147 148
148 // Now iterate over which node to update first, |k|. 149 // Now iterate over which node to update first, |k|.
149 for (int k = 0; k < tree_size; k++) { 150 for (int k = 0; k < tree_size; k++) {
150 SCOPED_TRACE("i=" + base::IntToString(i) + 151 SCOPED_TRACE("i=" + base::IntToString(i) +
151 " j=" + base::IntToString(j) + 152 " j=" + base::IntToString(j) +
152 " k=" + base::IntToString(k)); 153 " k=" + base::IntToString(k));
153 154
154 // Start by serializing tree0 and unserializing it into a new 155 // Start by serializing tree0 and unserializing it into a new
155 // empty tree |dst_tree|. 156 // empty tree |dst_tree|.
156 scoped_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData> > 157 std::unique_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData>>
157 tree0_source(tree0.CreateTreeSource()); 158 tree0_source(tree0.CreateTreeSource());
158 AXTreeSerializer<const AXNode*, AXNodeData, AXTreeData> serializer( 159 AXTreeSerializer<const AXNode*, AXNodeData, AXTreeData> serializer(
159 tree0_source.get()); 160 tree0_source.get());
160 AXTreeUpdate update0; 161 AXTreeUpdate update0;
161 ASSERT_TRUE(serializer.SerializeChanges(tree0.root(), &update0)); 162 ASSERT_TRUE(serializer.SerializeChanges(tree0.root(), &update0));
162 163
163 AXTree dst_tree; 164 AXTree dst_tree;
164 ASSERT_TRUE(dst_tree.Unserialize(update0)); 165 ASSERT_TRUE(dst_tree.Unserialize(update0));
165 166
166 // At this point, |dst_tree| should now be identical to |tree0|. 167 // At this point, |dst_tree| should now be identical to |tree0|.
167 EXPECT_EQ(TreeToString(tree0), TreeToString(dst_tree)); 168 EXPECT_EQ(TreeToString(tree0), TreeToString(dst_tree));
168 169
169 // Next, pretend that tree0 turned into tree1, and serialize 170 // Next, pretend that tree0 turned into tree1, and serialize
170 // a sequence of updates to |dst_tree| to match. 171 // a sequence of updates to |dst_tree| to match.
171 scoped_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData> > 172 std::unique_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData>>
172 tree1_source(tree1.CreateTreeSource()); 173 tree1_source(tree1.CreateTreeSource());
173 serializer.ChangeTreeSourceForTesting(tree1_source.get()); 174 serializer.ChangeTreeSourceForTesting(tree1_source.get());
174 175
175 for (int k_index = 0; k_index < tree_size; ++k_index) { 176 for (int k_index = 0; k_index < tree_size; ++k_index) {
176 int id = 1 + (k + k_index) % tree_size; 177 int id = 1 + (k + k_index) % tree_size;
177 AXTreeUpdate update; 178 AXTreeUpdate update;
178 ASSERT_TRUE( 179 ASSERT_TRUE(
179 serializer.SerializeChanges(tree1.GetFromId(id), &update)); 180 serializer.SerializeChanges(tree1.GetFromId(id), &update));
180 ASSERT_TRUE(dst_tree.Unserialize(update)); 181 ASSERT_TRUE(dst_tree.Unserialize(update));
181 } 182 }
182 183
183 // After the sequence of updates, |dst_tree| should now be 184 // After the sequence of updates, |dst_tree| should now be
184 // identical to |tree1|. 185 // identical to |tree1|.
185 EXPECT_EQ(TreeToString(tree1), TreeToString(dst_tree)); 186 EXPECT_EQ(TreeToString(tree1), TreeToString(dst_tree));
186 } 187 }
187 } 188 }
188 } 189 }
189 } 190 }
190 191
191 } // namespace ui 192 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accelerated_widget_mac/io_surface_context.h ('k') | ui/accessibility/ax_node_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698