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