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

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

Issue 903423002: Make FontList description-parsing public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge and apply review feedback Created 5 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 | « no previous file | ui/gfx/font_list.h » ('j') | ui/gfx/pango_util.cc » ('J')
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 "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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 MockResourceBundleDelegate delegate; 371 MockResourceBundleDelegate delegate;
372 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate); 372 ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
373 373
374 // Should be called once for each font type. When we return NULL the default 374 // Should be called once for each font type. When we return NULL the default
375 // font will be created. 375 // font will be created.
376 gfx::Font* test_font = nullptr; 376 gfx::Font* test_font = nullptr;
377 EXPECT_CALL(delegate, GetFontMock(_)) 377 EXPECT_CALL(delegate, GetFontMock(_))
378 .Times(16) 378 .Times(16)
379 .WillRepeatedly(Return(test_font)); 379 .WillRepeatedly(Return(test_font));
380 380
381 std::string expected = "test font, 12px";
382 EXPECT_CALL(delegate, GetLocalizedStringMock(IDS_UI_FONT_FAMILY_CROS)) 381 EXPECT_CALL(delegate, GetLocalizedStringMock(IDS_UI_FONT_FAMILY_CROS))
383 .WillOnce(Return(base::UTF8ToUTF16(expected))); 382 .WillOnce(Return(base::UTF8ToUTF16("test font, 12px")));
383 resource_bundle->ReloadFonts();
384 // Don't test the font name; it'll get mapped to something else by Fontconfig.
385 EXPECT_EQ(12, gfx::FontList().GetPrimaryFont().GetFontSize());
386 EXPECT_EQ(gfx::Font::NORMAL, gfx::FontList().GetPrimaryFont().GetStyle());
384 387
388 EXPECT_CALL(delegate, GetLocalizedStringMock(IDS_UI_FONT_FAMILY_CROS))
389 .WillOnce(Return(base::UTF8ToUTF16("test font 2, Bold 10px")));
385 resource_bundle->ReloadFonts(); 390 resource_bundle->ReloadFonts();
386 EXPECT_EQ(expected, gfx::FontList().GetFontDescriptionString()); 391 EXPECT_EQ(10, gfx::FontList().GetPrimaryFont().GetFontSize());
387 392 EXPECT_EQ(gfx::Font::BOLD, gfx::FontList().GetPrimaryFont().GetStyle());
388 expected = "test font 2, 12px";
389 EXPECT_CALL(delegate, GetLocalizedStringMock(IDS_UI_FONT_FAMILY_CROS))
390 .WillOnce(Return(base::UTF8ToUTF16(expected)));
391
392 resource_bundle->ReloadFonts();
393 EXPECT_EQ(expected, gfx::FontList().GetFontDescriptionString());
394 } 393 }
395 #endif 394 #endif
396 395
397 TEST_F(ResourceBundleTest, LocaleDataPakExists) { 396 TEST_F(ResourceBundleTest, LocaleDataPakExists) {
398 ResourceBundle* resource_bundle = CreateResourceBundle(NULL); 397 ResourceBundle* resource_bundle = CreateResourceBundle(NULL);
399 398
400 // Check that ResourceBundle::LocaleDataPakExists returns the correct results. 399 // Check that ResourceBundle::LocaleDataPakExists returns the correct results.
401 EXPECT_TRUE(resource_bundle->LocaleDataPakExists("en-US")); 400 EXPECT_TRUE(resource_bundle->LocaleDataPakExists("en-US"));
402 EXPECT_FALSE(resource_bundle->LocaleDataPakExists("not_a_real_locale")); 401 EXPECT_FALSE(resource_bundle->LocaleDataPakExists("not_a_real_locale"));
403 } 402 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE); 645 resource_bundle->AddDataPackFromPath(data_default_path, SCALE_FACTOR_NONE);
647 646
648 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3); 647 gfx::ImageSkia* image_skia = resource_bundle->GetImageSkiaNamed(3);
649 EXPECT_EQ(1u, image_skia->image_reps().size()); 648 EXPECT_EQ(1u, image_skia->image_reps().size());
650 EXPECT_TRUE(image_skia->image_reps()[0].unscaled()); 649 EXPECT_TRUE(image_skia->image_reps()[0].unscaled());
651 EXPECT_EQ(ui::SCALE_FACTOR_100P, 650 EXPECT_EQ(ui::SCALE_FACTOR_100P,
652 GetSupportedScaleFactor(image_skia->image_reps()[0].scale())); 651 GetSupportedScaleFactor(image_skia->image_reps()[0].scale()));
653 } 652 }
654 653
655 } // namespace ui 654 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/font_list.h » ('j') | ui/gfx/pango_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698