summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chrome_browser_main_mac_browsertest.mm
blob: 13a7a62872b369a12fbcbb14b21a553c36c88cdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/command_line.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/test_utils.h"
#import "testing/gtest_mac.h"
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/resource/resource_handle.h"
#include "ui/base/resource/scale_factor.h"
#include "ui/base/ui_base_switches.h"

namespace ui {

class ChromeBrowserMainMacBrowserTest : public InProcessBrowserTest {
 public:
  ChromeBrowserMainMacBrowserTest() {}

 protected:
  void SetUpCommandLine(base::CommandLine* command_line) override {
    // Activate Material Design mode by placing the MD switch on the command
    // line.
    command_line->AppendSwitchASCII(switches::kTopChromeMD,
                                    switches::kTopChromeMDMaterial);
  }
};

// Confirm that the Material Design resource packs are loaded and are the
// first packs in the vector (so that they are searched before the regular non-
// MD packs). TODO(shrike) - remove this test once Material Design replaces
// the old design.
IN_PROC_BROWSER_TEST_F(ChromeBrowserMainMacBrowserTest, MDResourceAccess) {
  // Make sure we're running in Material Design mode.
  ASSERT_TRUE(MaterialDesignController::IsModeMaterial());

  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  int counter = 0;
  for (const auto& pack : rb.data_packs_) {
    switch (counter) {
      case 0:
        // The first pack should be Material Design at 1x.
        EXPECT_TRUE(pack->HasOnlyMaterialDesignAssets());
        EXPECT_EQ(SCALE_FACTOR_100P, pack->GetScaleFactor());
        break;

      case 1:
        // The Second pack should be Material Design at 2x.
        EXPECT_TRUE(pack->HasOnlyMaterialDesignAssets());
        EXPECT_EQ(SCALE_FACTOR_200P, pack->GetScaleFactor());
        break;

      default:
        // All other packs should not be Material Design.
        EXPECT_FALSE(pack->HasOnlyMaterialDesignAssets());
        break;
    }
    counter++;
  }
}

}  // namespace ui