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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
8 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/scoped_temp_dir.h" | |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/themes/theme_service.h" | 14 #include "chrome/browser/themes/theme_service.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
17 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/color_utils.h" | 19 #include "ui/gfx/color_utils.h" |
20 | 20 |
21 using content::BrowserThread; | 21 using content::BrowserThread; |
22 using extensions::Extension; | 22 using extensions::Extension; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 std::map<int, FilePath> out_file_paths; | 386 std::map<int, FilePath> out_file_paths; |
387 ParseImageNamesJSON(images, &out_file_paths); | 387 ParseImageNamesJSON(images, &out_file_paths); |
388 | 388 |
389 EXPECT_FALSE(LoadRawBitmapsTo(out_file_paths)); | 389 EXPECT_FALSE(LoadRawBitmapsTo(out_file_paths)); |
390 } | 390 } |
391 | 391 |
392 // TODO(erg): This test should actually test more of the built resources from | 392 // TODO(erg): This test should actually test more of the built resources from |
393 // the extension data, but for now, exists so valgrind can test some of the | 393 // the extension data, but for now, exists so valgrind can test some of the |
394 // tricky memory stuff that BrowserThemePack does. | 394 // tricky memory stuff that BrowserThemePack does. |
395 TEST_F(BrowserThemePackTest, CanBuildAndReadPack) { | 395 TEST_F(BrowserThemePackTest, CanBuildAndReadPack) { |
396 ScopedTempDir dir; | 396 base::ScopedTempDir dir; |
397 ASSERT_TRUE(dir.CreateUniqueTempDir()); | 397 ASSERT_TRUE(dir.CreateUniqueTempDir()); |
398 FilePath file = dir.path().AppendASCII("data.pak"); | 398 FilePath file = dir.path().AppendASCII("data.pak"); |
399 | 399 |
400 // Part 1: Build the pack from an extension. | 400 // Part 1: Build the pack from an extension. |
401 { | 401 { |
402 FilePath star_gazing_path = GetStarGazingPath(); | 402 FilePath star_gazing_path = GetStarGazingPath(); |
403 FilePath manifest_path = | 403 FilePath manifest_path = |
404 star_gazing_path.AppendASCII("manifest.json"); | 404 star_gazing_path.AppendASCII("manifest.json"); |
405 std::string error; | 405 std::string error; |
406 JSONFileValueSerializer serializer(manifest_path); | 406 JSONFileValueSerializer serializer(manifest_path); |
(...skipping 16 matching lines...) Expand all Loading... |
423 | 423 |
424 // Part 2: Try to read back the data pack that we just wrote to disk. | 424 // Part 2: Try to read back the data pack that we just wrote to disk. |
425 { | 425 { |
426 scoped_refptr<BrowserThemePack> pack = | 426 scoped_refptr<BrowserThemePack> pack = |
427 BrowserThemePack::BuildFromDataPack( | 427 BrowserThemePack::BuildFromDataPack( |
428 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); | 428 file, "mblmlcbknbnfebdfjnolmcapmdofhmme"); |
429 ASSERT_TRUE(pack.get()); | 429 ASSERT_TRUE(pack.get()); |
430 VerifyStarGazing(pack.get()); | 430 VerifyStarGazing(pack.get()); |
431 } | 431 } |
432 } | 432 } |
OLD | NEW |