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
3 // found in the LICENSE file.
5 #include "chrome/browser/themes/theme_properties.h"
7 #include "testing/gtest/include/gtest/gtest.h"
11 typedef testing::Test ThemePropertiesTest
;
13 TEST_F(ThemePropertiesTest
, AlignmentConversion
) {
14 // Verify that we get out what we put in.
15 std::string top_left
= "left top";
16 int alignment
= ThemeProperties::StringToAlignment(top_left
);
17 EXPECT_EQ(ThemeProperties::ALIGN_TOP
| ThemeProperties::ALIGN_LEFT
,
19 EXPECT_EQ(top_left
, ThemeProperties::AlignmentToString(alignment
));
21 // We get back a normalized version of what we put in.
22 alignment
= ThemeProperties::StringToAlignment("top");
23 EXPECT_EQ(ThemeProperties::ALIGN_TOP
, alignment
);
24 EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment
));
26 alignment
= ThemeProperties::StringToAlignment("left");
27 EXPECT_EQ(ThemeProperties::ALIGN_LEFT
, alignment
);
28 EXPECT_EQ("left center", ThemeProperties::AlignmentToString(alignment
));
30 alignment
= ThemeProperties::StringToAlignment("right");
31 EXPECT_EQ(ThemeProperties::ALIGN_RIGHT
, alignment
);
32 EXPECT_EQ("right center", ThemeProperties::AlignmentToString(alignment
));
34 alignment
= ThemeProperties::StringToAlignment("righttopbottom");
35 EXPECT_EQ(ThemeProperties::ALIGN_CENTER
, alignment
);
36 EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment
));
39 TEST_F(ThemePropertiesTest
, AlignmentConversionInput
) {
40 // Verify that we output in an expected format.
41 int alignment
= ThemeProperties::StringToAlignment("bottom right");
42 EXPECT_EQ("right bottom", ThemeProperties::AlignmentToString(alignment
));
44 // Verify that bad strings don't cause explosions.
45 alignment
= ThemeProperties::StringToAlignment("new zealand");
46 EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment
));
48 // Verify that bad strings don't cause explosions.
49 alignment
= ThemeProperties::StringToAlignment("new zealand top");
50 EXPECT_EQ("center top", ThemeProperties::AlignmentToString(alignment
));
52 // Verify that bad strings don't cause explosions.
53 alignment
= ThemeProperties::StringToAlignment("new zealandtop");
54 EXPECT_EQ("center center", ThemeProperties::AlignmentToString(alignment
));