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

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: 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
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/stl_util.h"
12 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/accessibility/ax_node.h" 16 #include "ui/accessibility/ax_node.h"
16 #include "ui/accessibility/ax_serializable_tree.h" 17 #include "ui/accessibility/ax_serializable_tree.h"
17 #include "ui/accessibility/ax_tree_serializer.h" 18 #include "ui/accessibility/ax_tree_serializer.h"
18 19
19 using base::DoubleToString; 20 using base::DoubleToString;
20 using base::IntToString; 21 using base::IntToString;
21 using base::StringPrintf; 22 using base::StringPrintf;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 update.root_id = 1; 508 update.root_id = 1;
508 update.nodes[0].id = 1; 509 update.nodes[0].id = 1;
509 update.nodes[0].child_ids.push_back(3); 510 update.nodes[0].child_ids.push_back(3);
510 update.nodes[1].id = 3; 511 update.nodes[1].id = 3;
511 EXPECT_TRUE(tree.Unserialize(update)) << tree.error(); 512 EXPECT_TRUE(tree.Unserialize(update)) << tree.error();
512 std::vector<int> created = fake_delegate.node_creation_finished_ids(); 513 std::vector<int> created = fake_delegate.node_creation_finished_ids();
513 std::vector<int> subtree_reparented = 514 std::vector<int> subtree_reparented =
514 fake_delegate.subtree_reparented_finished_ids(); 515 fake_delegate.subtree_reparented_finished_ids();
515 std::vector<int> node_reparented = 516 std::vector<int> node_reparented =
516 fake_delegate.node_reparented_finished_ids(); 517 fake_delegate.node_reparented_finished_ids();
517 ASSERT_EQ(std::find(created.begin(), created.end(), 3), created.end()); 518 ASSERT(!base::ContainsValue(created, 3));
518 ASSERT_NE(std::find(subtree_reparented.begin(), subtree_reparented.end(), 3), 519 ASSERT(base::ContainsValue(subtree_reparented, 3));
519 subtree_reparented.end()); 520 ASSERT(!base::ContainsValue(node_reparented, 3));
sadrul 2017/06/14 02:43:01 Use ASSERT_FALSE/ASSERT_TRUE in the above.
Tripta 2017/06/14 05:46:17 Done.
520 ASSERT_EQ(std::find(node_reparented.begin(), node_reparented.end(), 3),
521 node_reparented.end());
522 } 521 }
523 522
524 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) { 523 TEST(AXTreeTest, TreeDelegateIsNotCalledForReparenting) {
525 AXTreeUpdate initial_state; 524 AXTreeUpdate initial_state;
526 initial_state.root_id = 1; 525 initial_state.root_id = 1;
527 initial_state.nodes.resize(2); 526 initial_state.nodes.resize(2);
528 initial_state.nodes[0].id = 1; 527 initial_state.nodes[0].id = 1;
529 initial_state.nodes[0].child_ids.push_back(2); 528 initial_state.nodes[0].child_ids.push_back(2);
530 initial_state.nodes[1].id = 2; 529 initial_state.nodes[1].id = 2;
531 530
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 fake_delegate2.attribute_change_log(); 777 fake_delegate2.attribute_change_log();
779 ASSERT_EQ(3U, change_log2.size()); 778 ASSERT_EQ(3U, change_log2.size());
780 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]); 779 EXPECT_EQ("controlsIds changed from 2,2 to ", change_log2[0]);
781 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]); 780 EXPECT_EQ("detailsIds changed from 3 to 2,2", change_log2[1]);
782 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]); 781 EXPECT_EQ("flowtoIds changed from to 3", change_log2[2]);
783 782
784 tree.SetDelegate(NULL); 783 tree.SetDelegate(NULL);
785 } 784 }
786 785
787 } // namespace ui 786 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698