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

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

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/path_service.h" 12 #include "base/path_service.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "build/build_config.h" 14 #include "build/build_config.h"
16 #include "chrome/browser/themes/theme_properties.h" 15 #include "chrome/browser/themes/theme_properties.h"
17 #include "chrome/common/chrome_paths.h" 16 #include "chrome/common/chrome_paths.h"
18 #include "chrome/grit/theme_resources.h" 17 #include "chrome/grit/theme_resources.h"
19 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gfx/color_utils.h" 20 #include "ui/gfx/color_utils.h"
22 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
23 #include "ui/gfx/image/image_skia.h" 22 #include "ui/gfx/image/image_skia.h"
24 #include "ui/gfx/image/image_skia_rep.h" 23 #include "ui/gfx/image/image_skia_rep.h"
25 24
26 using content::BrowserThread;
27 using extensions::Extension; 25 using extensions::Extension;
28 26
29 // Maps scale factors (enum values) to file path. 27 // Maps scale factors (enum values) to file path.
30 // A similar typedef in BrowserThemePack is private. 28 // A similar typedef in BrowserThemePack is private.
31 typedef std::map<ui::ScaleFactor, base::FilePath> TestScaleFactorToFileMap; 29 typedef std::map<ui::ScaleFactor, base::FilePath> TestScaleFactorToFileMap;
32 30
33 // Maps image ids to maps of scale factors to file paths. 31 // Maps image ids to maps of scale factors to file paths.
34 // A similar typedef in BrowserThemePack is private. 32 // A similar typedef in BrowserThemePack is private.
35 typedef std::map<int, TestScaleFactorToFileMap> TestFilePathMap; 33 typedef std::map<int, TestScaleFactorToFileMap> TestFilePathMap;
36 34
37 class BrowserThemePackTest : public ::testing::Test { 35 class BrowserThemePackTest : public ::testing::Test {
38 public: 36 public:
39 BrowserThemePackTest() 37 BrowserThemePackTest() {
40 : message_loop(),
41 fake_ui_thread(BrowserThread::UI, &message_loop),
42 fake_file_thread(BrowserThread::FILE, &message_loop) {
43 std::vector<ui::ScaleFactor> scale_factors; 38 std::vector<ui::ScaleFactor> scale_factors;
44 scale_factors.push_back(ui::SCALE_FACTOR_100P); 39 scale_factors.push_back(ui::SCALE_FACTOR_100P);
45 scale_factors.push_back(ui::SCALE_FACTOR_200P); 40 scale_factors.push_back(ui::SCALE_FACTOR_200P);
46 scoped_set_supported_scale_factors_.reset( 41 scoped_set_supported_scale_factors_.reset(
47 new ui::test::ScopedSetSupportedScaleFactors(scale_factors)); 42 new ui::test::ScopedSetSupportedScaleFactors(scale_factors));
48 theme_pack_ = new BrowserThemePack(); 43 theme_pack_ = new BrowserThemePack();
49 } 44 }
50 45
51 // Transformation for link underline colors. 46 // Transformation for link underline colors.
52 SkColor BuildThirdOpacity(SkColor color_link) { 47 SkColor BuildThirdOpacity(SkColor color_link) {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 EXPECT_EQ(160, rep4.sk_bitmap().height()); 340 EXPECT_EQ(160, rep4.sk_bitmap().height());
346 // We expect the same colors and at locations scaled by 2 341 // We expect the same colors and at locations scaled by 2
347 // since this bitmap was scaled by 2. 342 // since this bitmap was scaled by 2.
348 for (size_t i = 0; i < normal.size(); ++i) { 343 for (size_t i = 0; i < normal.size(); ++i) {
349 int xy = 2 * normal[i].first; 344 int xy = 2 * normal[i].first;
350 SkColor color = normal[i].second; 345 SkColor color = normal[i].second;
351 EXPECT_EQ(color, rep4.sk_bitmap().getColor(xy, xy)); 346 EXPECT_EQ(color, rep4.sk_bitmap().getColor(xy, xy));
352 } 347 }
353 } 348 }
354 349
355 base::MessageLoop message_loop; 350 content::TestBrowserThreadBundle test_browser_thread_bundle_;
356 content::TestBrowserThread fake_ui_thread;
357 content::TestBrowserThread fake_file_thread;
358 351
359 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> 352 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors>
360 ScopedSetSupportedScaleFactors; 353 ScopedSetSupportedScaleFactors;
361 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; 354 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_;
362 scoped_refptr<BrowserThemePack> theme_pack_; 355 scoped_refptr<BrowserThemePack> theme_pack_;
363 }; 356 };
364 357
365 // 'ntp_section' used to correspond to ThemeProperties::COLOR_NTP_SECTION, 358 // 'ntp_section' used to correspond to ThemeProperties::COLOR_NTP_SECTION,
366 // but COLOR_NTP_SECTION was since removed because it was never used. 359 // but COLOR_NTP_SECTION was since removed because it was never used.
367 // While it was in use, COLOR_NTP_HEADER used 'ntp_section' as a fallback when 360 // While it was in use, COLOR_NTP_HEADER used 'ntp_section' as a fallback when
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 599 }
607 600
608 // Part 2: Try to read back the data pack that we just wrote to disk. 601 // Part 2: Try to read back the data pack that we just wrote to disk.
609 { 602 {
610 scoped_refptr<BrowserThemePack> pack = 603 scoped_refptr<BrowserThemePack> pack =
611 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag"); 604 BrowserThemePack::BuildFromDataPack(file, "gllekhaobjnhgeag");
612 ASSERT_TRUE(pack.get()); 605 ASSERT_TRUE(pack.get());
613 VerifyHiDpiTheme(pack.get()); 606 VerifyHiDpiTheme(pack.get());
614 } 607 }
615 } 608 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service_unittest.cc ('k') | chrome/browser/themes/theme_syncable_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698