OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "chrome/test/base/in_process_browser_test.h" | |
7 #include "content/public/test/test_utils.h" | |
8 #import "testing/gtest_mac.h" | |
9 #include "ui/base/material_design/material_design_controller.h" | |
10 #include "ui/base/resource/resource_bundle.h" | |
11 #include "ui/base/resource/resource_handle.h" | |
12 #include "ui/base/resource/scale_factor.h" | |
13 #include "ui/base/ui_base_switches.h" | |
14 | |
15 namespace ui { | |
16 | |
17 class ChromeBrowserMainMacBrowserTest : public InProcessBrowserTest { | |
18 public: | |
19 ChromeBrowserMainMacBrowserTest() {} | |
20 | |
21 protected: | |
22 void SetUpCommandLine(base::CommandLine* command_line) override { | |
23 // Activate Material Design mode by placing the MD switch on the command | |
24 // line. | |
25 command_line->AppendSwitchASCII(switches::kTopChromeMD, | |
26 switches::kTopChromeMDMaterial); | |
27 } | |
28 }; | |
29 | |
30 // Confirm that the Material Design resource packs are loaded and are the | |
31 // first packs in the vector (so that they are searched before the regular non- | |
32 // MD packs). TODO(shrike) - remove this test once Material Design replaces | |
33 // the old design. | |
34 IN_PROC_BROWSER_TEST_F(ChromeBrowserMainMacBrowserTest, MDResourceAccess) { | |
35 // Make sure we're running in Material Design mode. | |
36 ASSERT_TRUE(MaterialDesignController::IsModeMaterial()); | |
37 | |
38 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
39 int counter = 0; | |
40 for (const auto& pack : rb.data_packs_) { | |
41 switch (counter) { | |
42 case 0: | |
43 // The first pack should be Material Design at 1x. | |
44 EXPECT_TRUE(pack->HasOnlyMaterialDesignAssets()); | |
45 EXPECT_EQ(SCALE_FACTOR_100P, pack->GetScaleFactor()); | |
46 break; | |
47 | |
48 case 1: | |
49 // The Second pack should be Material Design at 2x. | |
50 EXPECT_TRUE(pack->HasOnlyMaterialDesignAssets()); | |
51 EXPECT_EQ(SCALE_FACTOR_200P, pack->GetScaleFactor()); | |
52 break; | |
53 | |
54 default: | |
55 // All other packs should not be Material Design. | |
56 EXPECT_FALSE(pack->HasOnlyMaterialDesignAssets()); | |
57 break; | |
58 } | |
59 counter++; | |
60 } | |
61 } | |
62 | |
63 } // namespace ui | |
OLD | NEW |