diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 03:00:25 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-04 03:00:25 +0000 |
commit | 62c23fec25ea15921d810a9aee9f88624c21c96d (patch) | |
tree | c64cc737413c2887c996cc470947b927b927f8f2 /chrome/browser/browser_theme_provider_unittest.cc | |
parent | 9d6c4fd4d0587102015b283c698cab8a9e8aa288 (diff) | |
download | chromium_src-62c23fec25ea15921d810a9aee9f88624c21c96d.zip chromium_src-62c23fec25ea15921d810a9aee9f88624c21c96d.tar.gz chromium_src-62c23fec25ea15921d810a9aee9f88624c21c96d.tar.bz2 |
Unittests for NTP alignment changes (separate CL for Try server purposes). See http://codereview.chromium.org/115910
BUG=12768
TEST=none
Review URL: http://codereview.chromium.org/115911
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_theme_provider_unittest.cc')
-rw-r--r-- | chrome/browser/browser_theme_provider_unittest.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/chrome/browser/browser_theme_provider_unittest.cc b/chrome/browser/browser_theme_provider_unittest.cc new file mode 100644 index 0000000..21afdd3 --- /dev/null +++ b/chrome/browser/browser_theme_provider_unittest.cc @@ -0,0 +1,49 @@ +// 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/browser_theme_provider.h" +#include "testing/gtest/include/gtest/gtest.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)); +} |