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

Side by Side Diff: ui/android/resources/resource_manager_impl_unittest.cc

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Very small changes from last pedrosimonneti@ review Created 5 years, 1 month 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 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 "cc/resources/ui_resource_bitmap.h" 5 #include "cc/resources/ui_resource_bitmap.h"
6 #include "cc/test/fake_layer_tree_host_client.h" 6 #include "cc/test/fake_layer_tree_host_client.h"
7 #include "cc/test/test_task_graph_runner.h" 7 #include "cc/test/test_task_graph_runner.h"
8 #include "cc/trees/layer_tree_host.h" 8 #include "cc/trees/layer_tree_host.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 TEST_F(ResourceManagerTest, PreloadEnsureResource) { 122 TEST_F(ResourceManagerTest, PreloadEnsureResource) {
123 const cc::UIResourceId kResourceId = 99; 123 const cc::UIResourceId kResourceId = 99;
124 PreloadResource(kTestResourceType); 124 PreloadResource(kTestResourceType);
125 EXPECT_CALL(*host_.get(), CreateUIResource(_)) 125 EXPECT_CALL(*host_.get(), CreateUIResource(_))
126 .WillOnce(Return(kResourceId)) 126 .WillOnce(Return(kResourceId))
127 .RetiresOnSaturation(); 127 .RetiresOnSaturation();
128 SetResourceAsLoaded(kTestResourceType); 128 SetResourceAsLoaded(kTestResourceType);
129 EXPECT_EQ(kResourceId, GetUIResourceId(kTestResourceType)); 129 EXPECT_EQ(kResourceId, GetUIResourceId(kTestResourceType));
130 } 130 }
131 131
132 TEST_F(ResourceManagerTest, ProcessCrushedSpriteFrameRects) {
133 const size_t kNumFrames = 3;
134
135 // Create input
136 std::vector<int> frame0 = {35, 30, 38, 165, 18, 12, 0, 70, 0, 146, 72, 2};
137 std::vector<int> frame1 = {};
138 std::vector<int> frame2 = {0, 0, 73, 0, 72, 72};
139 std::vector<std::vector<int>> frame_rects_vector;
140 frame_rects_vector.push_back(frame0);
141 frame_rects_vector.push_back(frame1);
142 frame_rects_vector.push_back(frame2);
143
144 // Create expected output
145 CrushedSpriteResource::SrcDstRects expected_rects(kNumFrames);
146 gfx::Rect frame0_rect0_src(38, 165, 18, 12);
147 gfx::Rect frame0_rect0_dst(35, 30, 18, 12);
148 gfx::Rect frame0_rect1_src(0, 146, 72, 2);
149 gfx::Rect frame0_rect1_dst(0, 70, 72, 2);
150 gfx::Rect frame2_rect0_src(73, 0, 72, 72);
151 gfx::Rect frame2_rect0_dst(0, 0, 72, 72);
152 expected_rects[0].push_back(
153 std::pair<gfx::Rect, gfx::Rect>(frame0_rect0_src, frame0_rect0_dst));
154 expected_rects[0].push_back(
155 std::pair<gfx::Rect, gfx::Rect>(frame0_rect1_src, frame0_rect1_dst));
156 expected_rects[2].push_back(
157 std::pair<gfx::Rect, gfx::Rect>(frame2_rect0_src, frame2_rect0_dst));
158
159 // Check actual against expected
160 CrushedSpriteResource::SrcDstRects actual_rects =
161 resource_manager_.ProcessCrushedSpriteFrameRects(frame_rects_vector);
162 EXPECT_EQ(kNumFrames, actual_rects.size());
163 for (size_t i = 0; i < kNumFrames; i++) {
164 EXPECT_EQ(expected_rects[i].size(), actual_rects[i].size());
165 for (size_t j = 0; j < actual_rects[i].size(); j++) {
166 EXPECT_EQ(expected_rects[i][j], actual_rects[i][j]);
167 }
168 }
169 }
170
132 } // namespace ui 171 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698