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: chrome/browser/themes/browser_theme_pack_unittest.cc

Issue 2667753004: Themes: Remove unused IDs from ThemeProperties (Closed)
Patch Set: Remove {} and update/add comments 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 | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome/browser/themes/theme_properties.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 (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 "chrome/browser/themes/browser_theme_pack.h" 5 #include "chrome/browser/themes/browser_theme_pack.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 base::MessageLoop message_loop; 363 base::MessageLoop message_loop;
364 content::TestBrowserThread fake_ui_thread; 364 content::TestBrowserThread fake_ui_thread;
365 content::TestBrowserThread fake_file_thread; 365 content::TestBrowserThread fake_file_thread;
366 366
367 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> 367 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors>
368 ScopedSetSupportedScaleFactors; 368 ScopedSetSupportedScaleFactors;
369 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; 369 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_;
370 scoped_refptr<BrowserThemePack> theme_pack_; 370 scoped_refptr<BrowserThemePack> theme_pack_;
371 }; 371 };
372 372
373 373 // 'ntp_section' used to correspond to ThemeProperties::COLOR_NTP_SECTION,
374 TEST_F(BrowserThemePackTest, DeriveUnderlineLinkColor) { 374 // but COLOR_NTP_SECTION was since removed because it was never used.
375 // If we specify a link color, but don't specify the underline color, the 375 // While it was in use, COLOR_NTP_HEADER used 'ntp_section' as a fallback when
376 // theme provider should create one. 376 // 'ntp_header' was absent. We still preserve this fallback for themes that
377 std::string color_json = "{ \"ntp_link\": [128, 128, 128]," 377 // relied on this.
378 " \"ntp_section_link\": [128, 128, 128] }";
379 LoadColorJSON(color_json);
380
381 std::map<int, SkColor> colors = GetDefaultColorMap();
382 SkColor link_color = SkColorSetRGB(128, 128, 128);
383 colors[ThemeProperties::COLOR_NTP_LINK] = link_color;
384 colors[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] =
385 BuildThirdOpacity(link_color);
386 colors[ThemeProperties::COLOR_NTP_SECTION_LINK] = link_color;
387 colors[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] =
388 BuildThirdOpacity(link_color);
389
390 VerifyColorMap(colors);
391 }
392
393 TEST_F(BrowserThemePackTest, ProvideUnderlineLinkColor) {
394 // If we specify the underline color, it shouldn't try to generate one.
395 std::string color_json = "{ \"ntp_link\": [128, 128, 128],"
396 " \"ntp_link_underline\": [255, 255, 255],"
397 " \"ntp_section_link\": [128, 128, 128],"
398 " \"ntp_section_link_underline\": [255, 255, 255]"
399 "}";
400 LoadColorJSON(color_json);
401
402 std::map<int, SkColor> colors = GetDefaultColorMap();
403 SkColor link_color = SkColorSetRGB(128, 128, 128);
404 SkColor underline_color = SkColorSetRGB(255, 255, 255);
405 colors[ThemeProperties::COLOR_NTP_LINK] = link_color;
406 colors[ThemeProperties::COLOR_NTP_LINK_UNDERLINE] = underline_color;
407 colors[ThemeProperties::COLOR_NTP_SECTION_LINK] = link_color;
408 colors[ThemeProperties::COLOR_NTP_SECTION_LINK_UNDERLINE] =
409 underline_color;
410
411 VerifyColorMap(colors);
412 }
413
414 TEST_F(BrowserThemePackTest, UseSectionColorAsNTPHeader) { 378 TEST_F(BrowserThemePackTest, UseSectionColorAsNTPHeader) {
415 std::string color_json = "{ \"ntp_section\": [190, 190, 190] }"; 379 std::string color_json = "{ \"ntp_section\": [190, 190, 190] }";
416 LoadColorJSON(color_json); 380 LoadColorJSON(color_json);
417 381
418 std::map<int, SkColor> colors = GetDefaultColorMap(); 382 std::map<int, SkColor> colors = GetDefaultColorMap();
419 SkColor ntp_color = SkColorSetRGB(190, 190, 190); 383 SkColor ntp_color = SkColorSetRGB(190, 190, 190);
420 colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_color; 384 colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_color;
421 colors[ThemeProperties::COLOR_NTP_SECTION] = ntp_color;
422 VerifyColorMap(colors); 385 VerifyColorMap(colors);
423 } 386 }
424 387
425 TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) { 388 TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) {
426 std::string color_json = "{ \"ntp_header\": [120, 120, 120], " 389 std::string color_json = "{ \"ntp_header\": [120, 120, 120], "
427 " \"ntp_section\": [190, 190, 190] }"; 390 " \"ntp_section\": [190, 190, 190] }";
428 LoadColorJSON(color_json); 391 LoadColorJSON(color_json);
429 392
430 std::map<int, SkColor> colors = GetDefaultColorMap(); 393 std::map<int, SkColor> colors = GetDefaultColorMap();
431 colors[ThemeProperties::COLOR_NTP_HEADER] = SkColorSetRGB(120, 120, 120); 394 colors[ThemeProperties::COLOR_NTP_HEADER] = SkColorSetRGB(120, 120, 120);
432 colors[ThemeProperties::COLOR_NTP_SECTION] = SkColorSetRGB(190, 190, 190);
433 VerifyColorMap(colors); 395 VerifyColorMap(colors);
434 } 396 }
435 397
436 TEST_F(BrowserThemePackTest, SupportsAlpha) { 398 TEST_F(BrowserThemePackTest, SupportsAlpha) {
437 std::string color_json = 399 std::string color_json =
438 "{ \"toolbar\": [0, 20, 40, 1], " 400 "{ \"toolbar\": [0, 20, 40, 1], "
439 " \"tab_text\": [60, 80, 100, 1], " 401 " \"tab_text\": [60, 80, 100, 1], "
440 " \"tab_background_text\": [120, 140, 160, 0.0], " 402 " \"tab_background_text\": [120, 140, 160, 0.0], "
441 " \"bookmark_text\": [180, 200, 220, 1.0], " 403 " \"bookmark_text\": [180, 200, 220, 1.0], "
442 " \"ntp_text\": [240, 255, 0, 0.5] }"; 404 " \"ntp_text\": [240, 255, 0, 0.5] }";
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 614 }
653 615
654 // Part 2: Try to read back the data pack that we just wrote to disk. 616 // Part 2: Try to read back the data pack that we just wrote to disk.
655 { 617 {
656 scoped_refptr<BrowserThemePack> pack = 618 scoped_refptr<BrowserThemePack> pack =
657 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); 619 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag");
658 ASSERT_TRUE(pack.get()); 620 ASSERT_TRUE(pack.get());
659 VerifyHiDpiTheme(pack.get()); 621 VerifyHiDpiTheme(pack.get());
660 } 622 }
661 } 623 }
OLDNEW
« no previous file with comments | « chrome/browser/themes/browser_theme_pack.cc ('k') | chrome/browser/themes/theme_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698