| OLD | NEW |
| 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 "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "ui/gfx/color_utils.h" | 18 #include "ui/gfx/color_utils.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
| 21 #include "ui/gfx/image/image_skia_rep.h" | 21 #include "ui/gfx/image/image_skia_rep.h" |
| 22 #if defined(OS_WIN) |
| 23 #include "ui/gfx/win/dpi.h" |
| 24 #endif |
| 22 | 25 |
| 23 using content::BrowserThread; | 26 using content::BrowserThread; |
| 24 using extensions::Extension; | 27 using extensions::Extension; |
| 25 | 28 |
| 26 // Maps scale factors (enum values) to file path. | 29 // Maps scale factors (enum values) to file path. |
| 27 // A similar typedef in BrowserThemePack is private. | 30 // A similar typedef in BrowserThemePack is private. |
| 28 typedef std::map<ui::ScaleFactor, base::FilePath> TestScaleFactorToFileMap; | 31 typedef std::map<ui::ScaleFactor, base::FilePath> TestScaleFactorToFileMap; |
| 29 | 32 |
| 30 // Maps image ids to maps of scale factors to file paths. | 33 // Maps image ids to maps of scale factors to file paths. |
| 31 // A similar typedef in BrowserThemePack is private. | 34 // A similar typedef in BrowserThemePack is private. |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 589 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
| 587 ASSERT_TRUE(pack.get()); | 590 ASSERT_TRUE(pack.get()); |
| 588 VerifyStarGazing(pack.get()); | 591 VerifyStarGazing(pack.get()); |
| 589 } | 592 } |
| 590 } | 593 } |
| 591 | 594 |
| 592 TEST_F(BrowserThemePackTest, HiDpiThemeTest) { | 595 TEST_F(BrowserThemePackTest, HiDpiThemeTest) { |
| 593 base::ScopedTempDir dir; | 596 base::ScopedTempDir dir; |
| 594 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 597 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
| 595 base::FilePath file = dir.path().AppendASCII("theme_data.pak"); | 598 base::FilePath file = dir.path().AppendASCII("theme_data.pak"); |
| 599 #if defined(OS_WIN) |
| 600 if (gfx::IsHighDPIEnabled()) |
| 601 return; |
| 602 #endif |
| 596 | 603 |
| 597 // Part 1: Build the pack from an extension. | 604 // Part 1: Build the pack from an extension. |
| 598 { | 605 { |
| 599 base::FilePath hidpi_path = GetHiDpiThemePath(); | 606 base::FilePath hidpi_path = GetHiDpiThemePath(); |
| 600 scoped_refptr<BrowserThemePack> pack; | 607 scoped_refptr<BrowserThemePack> pack; |
| 601 BuildFromUnpackedExtension(hidpi_path, pack); | 608 BuildFromUnpackedExtension(hidpi_path, pack); |
| 602 ASSERT_TRUE(pack->WriteToDisk(file)); | 609 ASSERT_TRUE(pack->WriteToDisk(file)); |
| 603 VerifyHiDpiTheme(pack.get()); | 610 VerifyHiDpiTheme(pack.get()); |
| 604 } | 611 } |
| 605 | 612 |
| 606 // Part 2: Try to read back the data pack that we just wrote to disk. | 613 // Part 2: Try to read back the data pack that we just wrote to disk. |
| 607 { | 614 { |
| 608 scoped_refptr<BrowserThemePack> pack = | 615 scoped_refptr<BrowserThemePack> pack = |
| 609 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); | 616 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); |
| 610 ASSERT_TRUE(pack.get()); | 617 ASSERT_TRUE(pack.get()); |
| 611 VerifyHiDpiTheme(pack.get()); | 618 VerifyHiDpiTheme(pack.get()); |
| 612 } | 619 } |
| 613 } | 620 } |
| OLD | NEW |