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

Side by Side Diff: cc/base/spiral_iterator_unittest.cc

Issue 2067213002: cc: Implement tile iteration order based on pyramid sequence. [old] Base URL: https://chromium.googlesource.com/chromium/src.git@tiling_data_fix
Patch Set: rebase -> used for smoothness tests Created 3 years, 10 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 | « cc/base/spiral_iterator.cc ('k') | cc/base/switches.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/base/tiling_data.h" 10 #include "cc/base/tiling_data.h"
11 #include "cc/test/geometry_test_utils.h" 11 #include "cc/test/geometry_test_utils.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace cc { 14 namespace cc {
15 namespace { 15 namespace {
16 16
17 void TestSpiralIterate(int source_line_number, 17 void TestSpiralIterate(int source_line_number,
18 const TilingData& tiling_data, 18 const TilingData& tiling_data,
19 const gfx::Rect& consider, 19 const gfx::Rect& consider,
20 const gfx::Rect& ignore, 20 const gfx::Rect& ignore,
21 const gfx::Rect& center, 21 const gfx::Rect& center,
22 const std::vector<std::pair<int, int>>& expected) { 22 const std::vector<std::pair<int, int>>& expected) {
23 std::vector<std::pair<int, int>> actual_forward; 23 std::vector<std::pair<int, int>> actual_forward;
24 for (TilingData::SpiralDifferenceIterator it(&tiling_data, consider, ignore, 24 for (TilingData::SpiralDifferenceIterator it(&tiling_data, consider, ignore,
25 center); 25 center, false);
26 it; ++it) { 26 it; ++it) {
27 actual_forward.push_back(it.index()); 27 actual_forward.push_back(it.index());
28 } 28 }
29 29
30 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line " 30 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line "
31 << source_line_number; 31 << source_line_number;
32 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size()); 32 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size());
33 ++i) { 33 ++i) {
34 EXPECT_EQ(expected[i].first, actual_forward[i].first) 34 EXPECT_EQ(expected[i].first, actual_forward[i].first)
35 << "i: " << i << " error from line: " << source_line_number; 35 << "i: " << i << " error from line: " << source_line_number;
36 EXPECT_EQ(expected[i].second, actual_forward[i].second) 36 EXPECT_EQ(expected[i].second, actual_forward[i].second)
37 << "i: " << i << " error from line: " << source_line_number; 37 << "i: " << i << " error from line: " << source_line_number;
38 } 38 }
39 39
40 std::vector<std::pair<int, int>> actual_reverse; 40 std::vector<std::pair<int, int>> actual_reverse;
41 for (TilingData::ReverseSpiralDifferenceIterator it(&tiling_data, consider, 41 for (TilingData::ReverseSpiralDifferenceIterator it(&tiling_data, consider,
42 ignore, center); 42 ignore, center, false);
43 it; ++it) { 43 it; ++it) {
44 actual_reverse.push_back(it.index()); 44 actual_reverse.push_back(it.index());
45 } 45 }
46 46
47 std::vector<std::pair<int, int>> reversed_expected = expected; 47 std::vector<std::pair<int, int>> reversed_expected = expected;
48 std::reverse(reversed_expected.begin(), reversed_expected.end()); 48 std::reverse(reversed_expected.begin(), reversed_expected.end());
49 EXPECT_EQ(reversed_expected.size(), actual_reverse.size()) 49 EXPECT_EQ(reversed_expected.size(), actual_reverse.size())
50 << "error from line " << source_line_number; 50 << "error from line " << source_line_number;
51 for (size_t i = 0; 51 for (size_t i = 0;
52 i < std::min(reversed_expected.size(), actual_reverse.size()); ++i) { 52 i < std::min(reversed_expected.size(), actual_reverse.size()); ++i) {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 expected.clear(); 689 expected.clear();
690 expected.push_back(std::make_pair(0, 0)); 690 expected.push_back(std::make_pair(0, 0));
691 691
692 TestSpiralIterate(__LINE__, smaller_tiling, consider, ignore, center, 692 TestSpiralIterate(__LINE__, smaller_tiling, consider, ignore, center,
693 expected); 693 expected);
694 } 694 }
695 695
696 } // namespace 696 } // namespace
697 697
698 } // namespace cc 698 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/spiral_iterator.cc ('k') | cc/base/switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698