summaryrefslogtreecommitdiffstats
path: root/chrome/browser/themes/theme_properties_unittest.cc
blob: 46941ca93ef47be1291436716b442761297e215a (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
// Copyright (c) 2012 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 "chrome/browser/themes/theme_properties.h"

#include "testing/gtest/include/gtest/gtest.h"

namespace {

typedef testing::Test ThemePropertiesTest;

TEST_F(ThemePropertiesTest, AlignmentConversion) {
  // Verify that we get out what we put in.
  std::string top_left = "left top";
  int alignment = ThemeProperties::StringToAlignment(top_left);
  EXPECT_EQ(ThemeProperties::ALIGN_TOP | ThemeProperties::ALIGN_LEFT,
            alignment);
  EXPECT_EQ(top_left, ThemeProperties::AlignmentToString(alignment));

  // We get back a normalized version of what we put in.
  alignment = ThemeProperties::StringToAlignment("top");
  EXPECT_EQ(ThemeProperties::ALIGN_TOP, alignment);
  EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment));

  alignment = ThemeProperties::StringToAlignment("left");
  EXPECT_EQ(ThemeProperties::ALIGN_LEFT, alignment);
  EXPECT_EQ("left center", ThemeProperties::AlignmentToString(alignment));

  alignment = ThemeProperties::StringToAlignment("right");
  EXPECT_EQ(ThemeProperties::ALIGN_RIGHT, alignment);
  EXPECT_EQ("right center", ThemeProperties::AlignmentToString(alignment));

  alignment = ThemeProperties::StringToAlignment("righttopbottom");
  EXPECT_EQ(ThemeProperties::ALIGN_CENTER, alignment);
  EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment));
}

TEST_F(ThemePropertiesTest, AlignmentConversionInput) {
  // Verify that we output in an expected format.
  int alignment = ThemeProperties::StringToAlignment("bottom right");
  EXPECT_EQ("right bottom", ThemeProperties::AlignmentToString(alignment));

  // Verify that bad strings don't cause explosions.
  alignment = ThemeProperties::StringToAlignment("new zealand");
  EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment));

  // Verify that bad strings don't cause explosions.
  alignment = ThemeProperties::StringToAlignment("new zealand top");
  EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment));

  // Verify that bad strings don't cause explosions.
  alignment = ThemeProperties::StringToAlignment("new zealandtop");
  EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment));
}

}; // namespace