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

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

Issue 2930273002: Use ContainsValue() instead of std::find() in ui/accessibility, ui/gl and ui/ozone (Closed)
Patch Set: Rebase patch Created 3 years, 6 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/accessibility/ax_position.h ('k') | ui/gl/gl_implementation.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/accessibility/ax_tree.h" 5 #include "ui/accessibility/ax_tree.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/accessibility/ax_node.h" 17 #include "ui/accessibility/ax_node.h"
17 #include "ui/accessibility/ax_serializable_tree.h" 18 #include "ui/accessibility/ax_serializable_tree.h"
18 #include "ui/accessibility/ax_tree_serializer.h" 19 #include "ui/accessibility/ax_tree_serializer.h"
19 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
20 21
21 using base::DoubleToString; 22 using base::DoubleToString;
22 using base::IntToString; 23 using base::IntToString;
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 update.root_id = 1; 517 update.root_id = 1;
517 update.nodes[0].id = 1; 518 update.nodes[0].id = 1;
518 update.nodes[0].child_ids.push_back(3); 519 update.nodes[0].child_ids.push_back(3);
519 update.nodes[1].id = 3; 520 update.nodes[1].id = 3;
520 EXPECT_TRUE(tree.Unserialize(update)) << tree.error(); 521 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
521 std::vector<int> created = fake_delegate.node_creation_finished_ids(); 522 std::vector<int> created = fake_delegate.node_creation_finished_ids();
522 std::vector<int> subtree_reparented = 523 std::vector<int> subtree_reparented =
523 fake_delegate.subtree_reparented_finished_ids(); 524 fake_delegate.subtree_reparented_finished_ids();
524 std::vector<int> node_reparented = 525 std::vector<int> node_reparented =
525 fake_delegate.node_reparented_finished_ids(); 526 fake_delegate.node_reparented_finished_ids();
526 ASSERT_EQ(std::find(created.begin(), created.end(), 3), created.end()); 527 ASSERT_FALSE(base::ContainsValue(created, 3));
527 ASSERT_NE(std::find(subtree_reparented.begin(), subtree_reparented.end(), 3), 528 ASSERT_TRUE(base::ContainsValue(subtree_reparented, 3));
528 subtree_reparented.end()); 529 ASSERT_FALSE(base::ContainsValue(node_reparented, 3));
529 ASSERT_EQ(std::find(node_reparented.begin(), node_reparented.end(), 3),
530 node_reparented.end());
531 } 530 }
532 531
533 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) { 532 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) {
534 AXTreeUpdate initial_state; 533 AXTreeUpdate initial_state;
535 initial_state.root_id = 1; 534 initial_state.root_id = 1;
536 initial_state.nodes.resize(2); 535 initial_state.nodes.resize(2);
537 initial_state.nodes[0].id = 1; 536 initial_state.nodes[0].id = 1;
538 initial_state.nodes[0].child_ids.push_back(2); 537 initial_state.nodes[0].child_ids.push_back(2);
539 initial_state.nodes[1].id = 2; 538 initial_state.nodes[1].id = 2;
540 539
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 tree_update.nodes[1].child_ids.push_back(3); 895 tree_update.nodes[1].child_ids.push_back(3);
897 tree_update.nodes[2].id = 3; 896 tree_update.nodes[2].id = 3;
898 tree_update.nodes[2].offset_container_id = 2; 897 tree_update.nodes[2].offset_container_id = 2;
899 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5); 898 tree_update.nodes[2].location = gfx::RectF(20, 30, 50, 5);
900 899
901 AXTree tree(tree_update); 900 AXTree tree(tree_update);
902 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3)); 901 EXPECT_EQ("(115, 70) size (50 x 5)", GetBoundsAsString(tree, 3));
903 } 902 }
904 903
905 } // namespace ui 904 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/ax_position.h ('k') | ui/gl/gl_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698