| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Unit tests for BrowserDistribution class. | 5 // Unit tests for BrowserDistribution class. |
| 6 | 6 |
| 7 #include "chrome/installer/util/browser_distribution.h" | 7 #include "chrome/installer/util/browser_distribution.h" |
| 8 #include "chrome/installer/util/master_preferences.h" | |
| 9 #include "chrome/installer/util/shell_util.h" | 8 #include "chrome/installer/util/shell_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 10 |
| 12 namespace { | 11 namespace { |
| 13 class BrowserDistributionTest : public testing::Test { | 12 class BrowserDistributionTest : public testing::Test { |
| 14 protected: | 13 protected: |
| 15 virtual void SetUp() { | 14 virtual void SetUp() { |
| 16 // Currently no setup required. | 15 // Currently no setup required. |
| 17 } | 16 } |
| 18 | 17 |
| 19 virtual void TearDown() { | 18 virtual void TearDown() { |
| 20 // Currently no tear down required. | 19 // Currently no tear down required. |
| 21 } | 20 } |
| 22 }; | 21 }; |
| 23 } // namespace | 22 } // namespace |
| 24 | 23 |
| 25 // The distribution strings should not be empty. The unit tests are not linking | 24 // The distribution strings should not be empty. The unit tests are not linking |
| 26 // with the chrome resources so we cannot test official build. | 25 // with the chrome resources so we cannot test official build. |
| 27 TEST(BrowserDistributionTest, StringsTest) { | 26 TEST(BrowserDistributionTest, StringsTest) { |
| 28 struct browser_test_type { | 27 BrowserDistribution::Type browser_tests[] = { |
| 29 BrowserDistribution::Type type; | 28 BrowserDistribution::CHROME_BROWSER, |
| 30 bool has_com_dlls; | 29 BrowserDistribution::CHROME_FRAME, |
| 31 } browser_tests[] = { | |
| 32 { BrowserDistribution::CHROME_BROWSER, false }, | |
| 33 { BrowserDistribution::CHROME_FRAME, true }, | |
| 34 }; | 30 }; |
| 35 | 31 |
| 36 const installer::MasterPreferences& prefs = | |
| 37 installer::MasterPreferences::ForCurrentProcess(); | |
| 38 | |
| 39 for (int i = 0; i < arraysize(browser_tests); ++i) { | 32 for (int i = 0; i < arraysize(browser_tests); ++i) { |
| 40 BrowserDistribution* dist = | 33 BrowserDistribution* dist = |
| 41 BrowserDistribution::GetSpecificDistribution(browser_tests[i].type, | 34 BrowserDistribution::GetSpecificDistribution(browser_tests[i]); |
| 42 prefs); | |
| 43 ASSERT_TRUE(dist != NULL); | 35 ASSERT_TRUE(dist != NULL); |
| 44 std::wstring name = dist->GetApplicationName(); | 36 std::wstring name = dist->GetApplicationName(); |
| 45 EXPECT_FALSE(name.empty()); | 37 EXPECT_FALSE(name.empty()); |
| 46 std::wstring desc = dist->GetAppDescription(); | 38 std::wstring desc = dist->GetAppDescription(); |
| 47 EXPECT_FALSE(desc.empty()); | 39 EXPECT_FALSE(desc.empty()); |
| 48 std::wstring alt_name = dist->GetAlternateApplicationName(); | 40 std::wstring alt_name = dist->GetAlternateApplicationName(); |
| 49 EXPECT_FALSE(alt_name.empty()); | 41 EXPECT_FALSE(alt_name.empty()); |
| 50 std::vector<FilePath> com_dlls(dist->GetComDllList()); | |
| 51 if (browser_tests[i].has_com_dlls) { | |
| 52 EXPECT_FALSE(com_dlls.empty()); | |
| 53 } else { | |
| 54 EXPECT_TRUE(com_dlls.empty()); | |
| 55 } | |
| 56 } | 42 } |
| 57 } | 43 } |
| 58 | 44 |
| 59 // The shortcut strings obtained by the shell utility functions should not | 45 // The shortcut strings obtained by the shell utility functions should not |
| 60 // be empty or be the same. | 46 // be empty or be the same. |
| 61 TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { | 47 TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { |
| 62 std::wstring normal_name; | 48 std::wstring normal_name; |
| 63 std::wstring alternate_name; | 49 std::wstring alternate_name; |
| 64 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 50 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
| 65 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, &normal_name, false)); | 51 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, &normal_name, false)); |
| 66 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, &alternate_name, true)); | 52 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, &alternate_name, true)); |
| 67 EXPECT_NE(normal_name, alternate_name); | 53 EXPECT_NE(normal_name, alternate_name); |
| 68 EXPECT_FALSE(normal_name.empty()); | 54 EXPECT_FALSE(normal_name.empty()); |
| 69 EXPECT_FALSE(alternate_name.empty()); | 55 EXPECT_FALSE(alternate_name.empty()); |
| 70 } | 56 } |
| OLD | NEW |