diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 20:41:43 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-30 20:41:43 +0000 |
commit | 0003f509cd63c23518dd20e62e871807ae973065 (patch) | |
tree | d6abb980a2683047e13d09397eca22f45d2f0725 /chrome_frame/test/util_unittests.cc | |
parent | 48e6bb66ca6e49d11d71ccc28e4b6d8ccac42765 (diff) | |
download | chromium_src-0003f509cd63c23518dd20e62e871807ae973065.zip chromium_src-0003f509cd63c23518dd20e62e871807ae973065.tar.gz chromium_src-0003f509cd63c23518dd20e62e871807ae973065.tar.bz2 |
CRLF->LF to avoid future patch failures on the try bots.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/util_unittests.cc')
-rw-r--r-- | chrome_frame/test/util_unittests.cc | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/chrome_frame/test/util_unittests.cc b/chrome_frame/test/util_unittests.cc index dc3d72d..cc2727b 100644 --- a/chrome_frame/test/util_unittests.cc +++ b/chrome_frame/test/util_unittests.cc @@ -1,79 +1,79 @@ -// Copyright (c) 2006-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 "base/file_version_info.h"
-#include "chrome_frame/test/chrome_frame_unittests.h"
-#include "chrome_frame/utils.h"
-
-const wchar_t kChannelName[] = L"-dev";
-const wchar_t kSuffix[] = L"-fix";
-
-TEST(UtilTests, AppendSuffixToChannelNameTest) {
- std::wstring str_base;
- std::wstring channel_name(kChannelName);
- std::wstring suffix(kSuffix);
-
- str_base = L"2.0-dev-bar";
- EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str());
-
- str_base = L"2.0-dev-fix-bar";
- EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str());
-
- str_base = L"2.0-dev-bar-dev-bar";
- EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-fix-bar-dev-bar", str_base.c_str());
-
- str_base = L"2.0";
- EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0", str_base.c_str());
-
- str_base = L"2.0-devvvv";
- EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-fixvvv", str_base.c_str());
-}
-
-TEST(UtilTests, RemoveSuffixFromStringTest) {
- std::wstring str_base;
- std::wstring channel_name(kChannelName);
- std::wstring suffix(kSuffix);
-
- str_base = L"2.0-dev-fix";
- EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev", str_base.c_str());
-
- str_base = L"2.0-dev-fix-full";
- EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-full", str_base.c_str());
-
- str_base = L"2.0";
- EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0", str_base.c_str());
-
- str_base = L"2.0-dev";
- EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev", str_base.c_str());
-
- str_base = L"2.0-fix";
- EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-fix", str_base.c_str());
-
- str_base = L"2.0-full-fix";
- EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-full-fix", str_base.c_str());
-
- str_base = L"2.0-dev-dev-fix";
- EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix));
- EXPECT_STREQ(L"2.0-dev-dev", str_base.c_str());
-}
-
-TEST(UtilTests, GetModuleVersionTest) {
- HMODULE mod = GetModuleHandle(L"kernel32.dll");
- EXPECT_NE(mod, static_cast<HMODULE>(NULL));
- wchar_t path[MAX_PATH] = {0};
- GetModuleFileName(mod, path, arraysize(path));
+// Copyright (c) 2006-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 "base/file_version_info.h" +#include "chrome_frame/test/chrome_frame_unittests.h" +#include "chrome_frame/utils.h" + +const wchar_t kChannelName[] = L"-dev"; +const wchar_t kSuffix[] = L"-fix"; + +TEST(UtilTests, AppendSuffixToChannelNameTest) { + std::wstring str_base; + std::wstring channel_name(kChannelName); + std::wstring suffix(kSuffix); + + str_base = L"2.0-dev-bar"; + EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str()); + + str_base = L"2.0-dev-fix-bar"; + EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-fix-bar", str_base.c_str()); + + str_base = L"2.0-dev-bar-dev-bar"; + EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-fix-bar-dev-bar", str_base.c_str()); + + str_base = L"2.0"; + EXPECT_FALSE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0", str_base.c_str()); + + str_base = L"2.0-devvvv"; + EXPECT_TRUE(AppendSuffixToChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-fixvvv", str_base.c_str()); +} + +TEST(UtilTests, RemoveSuffixFromStringTest) { + std::wstring str_base; + std::wstring channel_name(kChannelName); + std::wstring suffix(kSuffix); + + str_base = L"2.0-dev-fix"; + EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev", str_base.c_str()); + + str_base = L"2.0-dev-fix-full"; + EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-full", str_base.c_str()); + + str_base = L"2.0"; + EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0", str_base.c_str()); + + str_base = L"2.0-dev"; + EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev", str_base.c_str()); + + str_base = L"2.0-fix"; + EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-fix", str_base.c_str()); + + str_base = L"2.0-full-fix"; + EXPECT_FALSE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-full-fix", str_base.c_str()); + + str_base = L"2.0-dev-dev-fix"; + EXPECT_TRUE(RemoveSuffixFromChannelName(&str_base, channel_name, suffix)); + EXPECT_STREQ(L"2.0-dev-dev", str_base.c_str()); +} + +TEST(UtilTests, GetModuleVersionTest) { + HMODULE mod = GetModuleHandle(L"kernel32.dll"); + EXPECT_NE(mod, static_cast<HMODULE>(NULL)); + wchar_t path[MAX_PATH] = {0}; + GetModuleFileName(mod, path, arraysize(path)); // Use the method that goes to disk scoped_ptr<FileVersionInfo> base_info( @@ -89,32 +89,32 @@ TEST(UtilTests, GetModuleVersionTest) { // Make sure they give the same results. VS_FIXEDFILEINFO* fixed_info = base_info->fixed_file_info(); EXPECT_TRUE(fixed_info != NULL); -
- EXPECT_EQ(fixed_info->dwFileVersionMS, static_cast<DWORD>(high));
- EXPECT_EQ(fixed_info->dwFileVersionLS, static_cast<DWORD>(low));
-}
-
-TEST(UtilTests, HaveSameOrigin) {
- struct OriginCompare {
- const char* a;
- const char* b;
- bool same_origin;
- } test_cases[] = {
- { "", "", true },
- { "*", "*", true },
- { "*", "+", false },
- { "http://www.google.com/", "http://www.google.com/", true },
- { "http://www.google.com", "http://www.google.com/", true },
- { "http://www.google.com:80/", "http://www.google.com/", true },
- { "http://www.google.com:8080/", "http://www.google.com/", false },
- { "https://www.google.com/", "http://www.google.com/", false },
- { "http://docs.google.com/", "http://www.google.com/", false },
- { "https://www.google.com/", "https://www.google.com:443/", true },
- { "https://www.google.com/", "https://www.google.com:443", true },
- };
-
- for (int i = 0; i < arraysize(test_cases); ++i) {
- const OriginCompare& test = test_cases[i];
- EXPECT_EQ(test.same_origin, HaveSameOrigin(test.a, test.b));
- }
-}
+ + EXPECT_EQ(fixed_info->dwFileVersionMS, static_cast<DWORD>(high)); + EXPECT_EQ(fixed_info->dwFileVersionLS, static_cast<DWORD>(low)); +} + +TEST(UtilTests, HaveSameOrigin) { + struct OriginCompare { + const char* a; + const char* b; + bool same_origin; + } test_cases[] = { + { "", "", true }, + { "*", "*", true }, + { "*", "+", false }, + { "http://www.google.com/", "http://www.google.com/", true }, + { "http://www.google.com", "http://www.google.com/", true }, + { "http://www.google.com:80/", "http://www.google.com/", true }, + { "http://www.google.com:8080/", "http://www.google.com/", false }, + { "https://www.google.com/", "http://www.google.com/", false }, + { "http://docs.google.com/", "http://www.google.com/", false }, + { "https://www.google.com/", "https://www.google.com:443/", true }, + { "https://www.google.com/", "https://www.google.com:443", true }, + }; + + for (int i = 0; i < arraysize(test_cases); ++i) { + const OriginCompare& test = test_cases[i]; + EXPECT_EQ(test.same_origin, HaveSameOrigin(test.a, test.b)); + } +} |