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

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

Issue 322523002: Adding OverrideStringResource API to ResourceBundle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/big_endian.h" 8 #include "base/big_endian.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 int resource_id = 5; 301 int resource_id = 5;
302 302
303 EXPECT_CALL(delegate, GetLocalizedStringMock(resource_id)) 303 EXPECT_CALL(delegate, GetLocalizedStringMock(resource_id))
304 .Times(1) 304 .Times(1)
305 .WillOnce(Return(data)); 305 .WillOnce(Return(data));
306 306
307 base::string16 result = resource_bundle->GetLocalizedString(resource_id); 307 base::string16 result = resource_bundle->GetLocalizedString(resource_id);
308 EXPECT_EQ(data, result); 308 EXPECT_EQ(data, result);
309 } 309 }
310 310
311 TEST_F(ResourceBundleTest, OverrideStringResource) {
312 ResourceBundle* resource_bundle = CreateResourceBundle(NULL);
313
314 base::string16 data = base::ASCIIToUTF16("My test data");
315 int resource_id = 5;
316
grt (UTC plus 2) 2014/06/09 16:54:44 does it make sense to test that GetLocalizedString
jwd 2014/06/10 20:59:25 Done, but doesn't test the successful return of ac
317 resource_bundle->OverrideStringResource(resource_id, data);
318
319 base::string16 result = resource_bundle->GetLocalizedString(resource_id);
320 EXPECT_EQ(data, result);
321 }
322
323 TEST_F(ResourceBundleTest, DelegateGetLocalizedStringWithOverride) {
324 MockResourceBundleDelegate delegate;
325 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
326
327 base::string16 delegate_data = base::ASCIIToUTF16("My delegate data");
328 int resource_id = 5;
329
330 EXPECT_CALL(delegate, GetLocalizedStringMock(resource_id))
331 .Times(1)
332 .WillOnce(Return(delegate_data));
333
334 base::string16 override_data = base::ASCIIToUTF16("My override data");
335
336 base::string16 result = resource_bundle->GetLocalizedString(resource_id);
337 EXPECT_EQ(delegate_data, result);
338 }
339
311 #if defined(USE_OZONE) && !defined(USE_PANGO) 340 #if defined(USE_OZONE) && !defined(USE_PANGO)
312 #define MAYBE_DelegateGetFontList DISABLED_DelegateGetFontList 341 #define MAYBE_DelegateGetFontList DISABLED_DelegateGetFontList
313 #else 342 #else
314 #define MAYBE_DelegateGetFontList DelegateGetFontList 343 #define MAYBE_DelegateGetFontList DelegateGetFontList
315 #endif 344 #endif
316 345
317 TEST_F(ResourceBundleTest, MAYBE_DelegateGetFontList) { 346 TEST_F(ResourceBundleTest, MAYBE_DelegateGetFontList) {
318 MockResourceBundleDelegate delegate; 347 MockResourceBundleDelegate delegate;
319 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate); 348 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
320 349
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 612 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
584 613
585 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 614 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
586 EXPECT_EQ(1u, image_skia->image_reps().size()); 615 EXPECT_EQ(1u, image_skia->image_reps().size());
587 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); 616 EXPECT_TRUE(image_skia->image_reps()[0].unscaled());
588 EXPECT_EQ(ui::SCALE_FACTOR_100P, 617 EXPECT_EQ(ui::SCALE_FACTOR_100P,
589 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); 618 GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
590 } 619 }
591 620
592 } // namespace ui 621 } // namespace ui
OLDNEW
« ui/base/resource/resource_bundle.cc ('K') | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698