OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/shell_util.h" | 8 #include "chrome/installer/util/shell_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 // The distribution strings should not be empty. The unit tests are not linking | 11 // The distribution strings should not be empty. The unit tests are not linking |
12 // with the chrome resources so we cannot test official build. | 12 // with the chrome resources so we cannot test official build. |
13 TEST(BrowserDistributionTest, StringsTest) { | 13 TEST(BrowserDistributionTest, StringsTest) { |
14 for (size_t i = 0; i < BrowserDistribution::kNumProductTypes; ++i) { | 14 for (size_t i = 0; i < BrowserDistribution::kNumProductTypes; ++i) { |
15 BrowserDistribution* dist = | 15 BrowserDistribution* dist = |
16 BrowserDistribution::GetSpecificDistribution( | 16 BrowserDistribution::GetSpecificDistribution( |
17 BrowserDistribution::kProductTypes[i]); | 17 BrowserDistribution::kProductTypes[i]); |
18 ASSERT_TRUE(dist != NULL); | 18 ASSERT_TRUE(dist != NULL); |
19 std::wstring name = dist->GetApplicationName(); | 19 string16 name = dist->GetUnsuffixedAppName(); |
20 EXPECT_FALSE(name.empty()); | 20 EXPECT_FALSE(name.empty()); |
21 std::wstring desc = dist->GetAppDescription(); | 21 string16 suffixed_name = dist->GetAppName(); |
| 22 EXPECT_FALSE(suffixed_name.empty()); |
| 23 ASSERT_NE(string16::npos, suffixed_name.find(name)); |
| 24 string16 desc = dist->GetAppDescription(); |
22 EXPECT_FALSE(desc.empty()); | 25 EXPECT_FALSE(desc.empty()); |
23 std::wstring alt_name = dist->GetAlternateApplicationName(); | 26 string16 alt_name = dist->GetAlternateApplicationName(); |
24 EXPECT_FALSE(alt_name.empty()); | 27 EXPECT_FALSE(alt_name.empty()); |
25 } | 28 } |
26 } | 29 } |
27 | 30 |
28 // The shortcut strings obtained by the shell utility functions should not | 31 // The shortcut strings obtained by the shell utility functions should not |
29 // be empty or be the same. | 32 // be empty or be the same. |
30 TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { | 33 TEST(BrowserDistributionTest, AlternateAndNormalShortcutName) { |
31 std::wstring normal_name; | 34 string16 normal_name; |
32 std::wstring alternate_name; | 35 string16 alternate_name; |
33 std::wstring appended_name_one; | 36 string16 appended_name_one; |
34 std::wstring appended_name_two; | 37 string16 appended_name_two; |
35 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 38 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
36 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, L"", | 39 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, false, L"", |
37 &normal_name)); | 40 &normal_name)); |
38 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"", | 41 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"", |
39 &alternate_name)); | 42 &alternate_name)); |
40 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparky", | 43 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparky", |
41 &appended_name_one)); | 44 &appended_name_one)); |
42 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparkles", | 45 EXPECT_TRUE(ShellUtil::GetChromeShortcutName(dist, true, L"Sparkles", |
43 &appended_name_two)); | 46 &appended_name_two)); |
44 EXPECT_NE(normal_name, alternate_name); | 47 EXPECT_NE(normal_name, alternate_name); |
45 EXPECT_NE(appended_name_one, appended_name_two); | 48 EXPECT_NE(appended_name_one, appended_name_two); |
46 EXPECT_FALSE(normal_name.empty()); | 49 EXPECT_FALSE(normal_name.empty()); |
47 EXPECT_FALSE(alternate_name.empty()); | 50 EXPECT_FALSE(alternate_name.empty()); |
48 EXPECT_FALSE(appended_name_one.empty()); | 51 EXPECT_FALSE(appended_name_one.empty()); |
49 EXPECT_FALSE(appended_name_two.empty()); | 52 EXPECT_FALSE(appended_name_two.empty()); |
50 } | 53 } |
OLD | NEW |