summaryrefslogtreecommitdiffstats
path: root/chrome/browser/themes/browser_theme_provider_unittest.cc
blob: c99a946d30eccfafee47e3ae22d448860a4a7435 (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
// Copyright (c) 2009 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/browser_theme_provider.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "base/json/json_reader.h"

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

  alignment = BrowserThemeProvider::StringToAlignment("top");
  EXPECT_EQ(BrowserThemeProvider::ALIGN_TOP, alignment);
  EXPECT_EQ("top", BrowserThemeProvider::AlignmentToString(alignment));

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

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

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

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

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

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

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