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

Side by Side Diff: chrome/browser/themes/browser_theme_pack_unittest.cc

Issue 2667753004: Themes: Remove unused IDs from ThemeProperties (Closed)
Patch Set: Remove COLOR_NTP_SECTION 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
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
374 TEST_F(BrowserThemePackTest, DeriveUnderlineLinkColor) {
375 // If we specify a link color, but don't specify the underline color, the
376 // theme provider should create one.
377 std::string color_json = "{ \"ntp_link\": [128, 128, 128],"
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) { 373 TEST_F(BrowserThemePackTest, UseSectionColorAsNTPHeader) {
Evan Stade 2017/02/01 21:47:23 nit: since this is sorta more subtle now, add a co
Tom (Use chromium acct) 2017/02/01 23:09:30 Done.
415 std::string color_json = "{ \"ntp_section\": [190, 190, 190] }"; 374 std::string color_json = "{ \"ntp_section\": [190, 190, 190] }";
416 LoadColorJSON(color_json); 375 LoadColorJSON(color_json);
417 376
418 std::map<int, SkColor> colors = GetDefaultColorMap(); 377 std::map<int, SkColor> colors = GetDefaultColorMap();
419 SkColor ntp_color = SkColorSetRGB(190, 190, 190); 378 SkColor ntp_color = SkColorSetRGB(190, 190, 190);
420 colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_color; 379 colors[ThemeProperties::COLOR_NTP_HEADER] = ntp_color;
421 colors[ThemeProperties::COLOR_NTP_SECTION] = ntp_color;
422 VerifyColorMap(colors); 380 VerifyColorMap(colors);
423 } 381 }
424 382
425 TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) { 383 TEST_F(BrowserThemePackTest, ProvideNtpHeaderColor) {
426 std::string color_json = "{ \"ntp_header\": [120, 120, 120], " 384 std::string color_json = "{ \"ntp_header\": [120, 120, 120], "
427 " \"ntp_section\": [190, 190, 190] }"; 385 " \"ntp_section\": [190, 190, 190] }";
428 LoadColorJSON(color_json); 386 LoadColorJSON(color_json);
429 387
430 std::map<int, SkColor> colors = GetDefaultColorMap(); 388 std::map<int, SkColor> colors = GetDefaultColorMap();
431 colors[ThemeProperties::COLOR_NTP_HEADER] = SkColorSetRGB(120, 120, 120); 389 colors[ThemeProperties::COLOR_NTP_HEADER] = SkColorSetRGB(120, 120, 120);
432 colors[ThemeProperties::COLOR_NTP_SECTION] = SkColorSetRGB(190, 190, 190);
433 VerifyColorMap(colors); 390 VerifyColorMap(colors);
434 } 391 }
435 392
436 TEST_F(BrowserThemePackTest, SupportsAlpha) { 393 TEST_F(BrowserThemePackTest, SupportsAlpha) {
437 std::string color_json = 394 std::string color_json =
438 "{ \"toolbar\": [0, 20, 40, 1], " 395 "{ \"toolbar\": [0, 20, 40, 1], "
439 " \"tab_text\": [60, 80, 100, 1], " 396 " \"tab_text\": [60, 80, 100, 1], "
440 " \"tab_background_text\": [120, 140, 160, 0.0], " 397 " \"tab_background_text\": [120, 140, 160, 0.0], "
441 " \"bookmark_text\": [180, 200, 220, 1.0], " 398 " \"bookmark_text\": [180, 200, 220, 1.0], "
442 " \"ntp_text\": [240, 255, 0, 0.5] }"; 399 " \"ntp_text\": [240, 255, 0, 0.5] }";
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 } 609 }
653 610
654 // Part 2: Try to read back the data pack that we just wrote to disk. 611 // Part 2: Try to read back the data pack that we just wrote to disk.
655 { 612 {
656 scoped_refptr<BrowserThemePack> pack = 613 scoped_refptr<BrowserThemePack> pack =
657 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); 614 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag");
658 ASSERT_TRUE(pack.get()); 615 ASSERT_TRUE(pack.get());
659 VerifyHiDpiTheme(pack.get()); 616 VerifyHiDpiTheme(pack.get());
660 } 617 }
661 } 618 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698