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

Side by Side Diff: ui/base/resource/resource_bundle_unittest.cc

Issue 1601583002: Cleanup: Remove unused ui::ResourceBundle::ImageRTL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/base/resource/resource_bundle_mac.mm ('k') | ui/base/resource/resource_bundle_win.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 MockResourceBundleDelegate() { 65 MockResourceBundleDelegate() {
66 } 66 }
67 ~MockResourceBundleDelegate() override { 67 ~MockResourceBundleDelegate() override {
68 } 68 }
69 69
70 MOCK_METHOD2(GetPathForResourcePack, base::FilePath( 70 MOCK_METHOD2(GetPathForResourcePack, base::FilePath(
71 const base::FilePath& pack_path, ui::ScaleFactor scale_factor)); 71 const base::FilePath& pack_path, ui::ScaleFactor scale_factor));
72 MOCK_METHOD2(GetPathForLocalePack, base::FilePath( 72 MOCK_METHOD2(GetPathForLocalePack, base::FilePath(
73 const base::FilePath& pack_path, const std::string& locale)); 73 const base::FilePath& pack_path, const std::string& locale));
74 MOCK_METHOD1(GetImageNamed, gfx::Image(int resource_id)); 74 MOCK_METHOD1(GetImageNamed, gfx::Image(int resource_id));
75 MOCK_METHOD2(GetNativeImageNamed, 75 MOCK_METHOD1(GetNativeImageNamed, gfx::Image(int resource_id));
76 gfx::Image(int resource_id,
77 ui::ResourceBundle::ImageRTL rtl));
78 MOCK_METHOD2(LoadDataResourceBytes, 76 MOCK_METHOD2(LoadDataResourceBytes,
79 base::RefCountedStaticMemory*(int resource_id, 77 base::RefCountedStaticMemory*(int resource_id,
80 ui::ScaleFactor scale_factor)); 78 ui::ScaleFactor scale_factor));
81 MOCK_METHOD2(GetRawDataResourceMock, base::StringPiece( 79 MOCK_METHOD2(GetRawDataResourceMock, base::StringPiece(
82 int resource_id, 80 int resource_id,
83 ui::ScaleFactor scale_factor)); 81 ui::ScaleFactor scale_factor));
84 bool GetRawDataResource(int resource_id, 82 bool GetRawDataResource(int resource_id,
85 ui::ScaleFactor scale_factor, 83 ui::ScaleFactor scale_factor,
86 base::StringPiece* value) override { 84 base::StringPiece* value) override {
87 *value = GetRawDataResourceMock(resource_id, scale_factor); 85 *value = GetRawDataResourceMock(resource_id, scale_factor);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate); 241 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
244 242
245 gfx::Image empty_image = resource_bundle->GetEmptyImage(); 243 gfx::Image empty_image = resource_bundle->GetEmptyImage();
246 int resource_id = 5; 244 int resource_id = 5;
247 245
248 // Some platforms delegate GetNativeImageNamed calls to GetImageNamed. 246 // Some platforms delegate GetNativeImageNamed calls to GetImageNamed.
249 EXPECT_CALL(delegate, GetImageNamed(resource_id)) 247 EXPECT_CALL(delegate, GetImageNamed(resource_id))
250 .Times(Between(0, 1)) 248 .Times(Between(0, 1))
251 .WillOnce(Return(empty_image)); 249 .WillOnce(Return(empty_image));
252 EXPECT_CALL(delegate, 250 EXPECT_CALL(delegate,
253 GetNativeImageNamed(resource_id, ui::ResourceBundle::RTL_DISABLED)) 251 GetNativeImageNamed(resource_id))
254 .Times(Between(0, 1)) 252 .Times(Between(0, 1))
255 .WillOnce(Return(empty_image)); 253 .WillOnce(Return(empty_image));
256 254
257 gfx::Image result = resource_bundle->GetNativeImageNamed(resource_id); 255 gfx::Image result = resource_bundle->GetNativeImageNamed(resource_id);
258 EXPECT_EQ(empty_image.ToSkBitmap(), result.ToSkBitmap()); 256 EXPECT_EQ(empty_image.ToSkBitmap(), result.ToSkBitmap());
259 } 257 }
260 258
261 TEST_F(ResourceBundleTest, DelegateLoadDataResourceBytes) { 259 TEST_F(ResourceBundleTest, DelegateLoadDataResourceBytes) {
262 MockResourceBundleDelegate delegate; 260 MockResourceBundleDelegate delegate;
263 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate); 261 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 762 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
765 763
766 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 764 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
767 EXPECT_EQ(1u, image_skia->image_reps().size()); 765 EXPECT_EQ(1u, image_skia->image_reps().size());
768 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); 766 EXPECT_TRUE(image_skia->image_reps()[0].unscaled());
769 EXPECT_EQ(ui::SCALE_FACTOR_100P, 767 EXPECT_EQ(ui::SCALE_FACTOR_100P,
770 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); 768 GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
771 } 769 }
772 770
773 } // namespace ui 771 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle_mac.mm ('k') | ui/base/resource/resource_bundle_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698