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 #include "base/command_line.h" | |
4 #include "base/platform_thread.h" | 5 #include "base/platform_thread.h" |
6 #include "base/scoped_ptr.h" | |
5 #include "base/win_util.h" | 7 #include "base/win_util.h" |
6 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
7 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" | 9 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" |
10 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
9 | 12 |
10 #include "chrome_mini_installer.h" | 13 #include "chrome_mini_installer.h" |
11 | 14 |
15 // Although the C++ style guide disallows use of namespace directive, use | |
16 // here because this is not only a .cc file, but also a test. | |
17 using namespace mini_installer_constants; | |
18 | |
12 namespace { | 19 namespace { |
20 | |
13 class MiniInstallTest : public testing::Test { | 21 class MiniInstallTest : public testing::Test { |
14 protected: | 22 protected: |
15 void CleanTheSystem() { | 23 // Whether these tests should be run regardless of our running platform. |
16 ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall); | 24 bool force_tests_; |
25 | |
26 // Installers created in test fixture setup for convenience. | |
27 scoped_ptr<ChromeMiniInstaller> user_inst_, sys_inst_; | |
28 | |
29 public: | |
30 static void CleanTheSystem() { | |
kuchhal
2009/10/27 18:57:09
why static?
| |
31 ChromeMiniInstaller userinstall(kUserInstall); | |
17 userinstall.UnInstall(); | 32 userinstall.UnInstall(); |
18 ChromeMiniInstaller systeminstall( | 33 ChromeMiniInstaller systeminstall(kSystemInstall); |
19 mini_installer_constants::kSystemInstall); | 34 systeminstall.UnInstall(); |
20 systeminstall.UnInstall(); | |
21 } | 35 } |
36 | |
22 virtual void SetUp() { | 37 virtual void SetUp() { |
23 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { | 38 // Parse test command-line arguments. |
39 const CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
40 std::wstring build = cmd->GetSwitchValue(L"build"); | |
41 if (build.empty()) | |
42 build = L"latest"; | |
43 | |
44 force_tests_ = cmd->HasSwitch(L"force"); | |
45 | |
46 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA || | |
47 force_tests_) { | |
24 CleanTheSystem(); | 48 CleanTheSystem(); |
49 // Separate the test output from cleaning output | |
50 printf("\nBEGIN test----------------------------------------\n"); | |
51 | |
52 // Create a few differently configured installers that are used in | |
53 // the tests, for convenience. | |
54 user_inst_.reset(new ChromeMiniInstaller(kUserInstall)); | |
55 user_inst_->SetBuildUnderTest(build); | |
56 sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall)); | |
57 sys_inst_->SetBuildUnderTest(build); | |
58 | |
25 } else { | 59 } else { |
26 printf("These tests don't run on Vista\n"); | 60 printf("These tests don't run on this platform.\n"); |
27 exit(0); | 61 exit(0); |
28 } | 62 } |
29 } | 63 } |
30 virtual void TearDown() { | 64 |
31 if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { | 65 static void TearDownTestCase() { |
kuchhal
2009/10/27 18:57:09
Why static and why TearDownTestCase and not just T
kkania
2009/10/27 19:45:02
CleanTheSystem is called in SetUp already. I use T
| |
32 PlatformThread::Sleep(2000); | 66 // Uninstall Chrome from the system after tests are run. |
33 CleanTheSystem(); | 67 CleanTheSystem(); |
34 } else { | |
35 printf("These tests don't run on Vista\n"); | |
36 exit(0); | |
37 } | |
38 } | 68 } |
39 }; | 69 }; |
40 }; | 70 }; |
41 | 71 |
42 // TODO(nsylvain): Change this for GOOGLE_CHROME_BUILD when we have the | 72 #if defined(GOOGLE_CHROME_BUILD) |
43 // previous installers accessible from our Google Chrome continuous buildbot. | 73 // Could use a parameterized gtest to slim down this list of tests, but since |
44 #if defined(OFFICIAL_BUILD) | 74 // these tests will often be run manually, don't want to have obscure test |
45 TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTest) { | 75 // names. |
46 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 76 |
47 installer.InstallFullInstaller(false, | 77 // Install full installer. |
48 mini_installer_constants::kDevChannelBuild); | 78 TEST_F(MiniInstallTest, FullInstallerUser) { |
79 user_inst_->InstallFullInstaller(false); | |
80 } | |
81 TEST_F(MiniInstallTest, FullInstallerSys) { | |
82 sys_inst_->InstallFullInstaller(false); | |
49 } | 83 } |
50 | 84 |
51 TEST_F(MiniInstallTest, InstallLatestDevFullInstallerTestSystemLevel) { | 85 // Overinstall full installer. |
52 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | 86 TEST_F(MiniInstallTest, FullOverPreviousFullUser) { |
53 installer.InstallFullInstaller(false, | 87 user_inst_->OverInstallOnFullInstaller(kFullInstall); |
54 mini_installer_constants::kDevChannelBuild); | 88 } |
89 TEST_F(MiniInstallTest, FullOverPreviousFullSys) { | |
90 sys_inst_->OverInstallOnFullInstaller(kFullInstall); | |
55 } | 91 } |
56 | 92 |
57 TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTest) { | 93 // Overinstall diff installer. |
58 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 94 TEST_F(MiniInstallTest, DiffOverPreviousFullUser) { |
59 installer.InstallFullInstaller(false, | 95 user_inst_->OverInstallOnFullInstaller(kDiffInstall); |
60 mini_installer_constants::kStableChannelBuild); | 96 } |
97 TEST_F(MiniInstallTest, DiffOverPreviousFullSys) { | |
98 sys_inst_->OverInstallOnFullInstaller(kDiffInstall); | |
61 } | 99 } |
62 | 100 |
63 TEST_F(MiniInstallTest, InstallLatestStableFullInstallerTestSystemLevel) { | 101 // Repair version folder. |
64 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | 102 TEST_F(MiniInstallTest, RepairFolderOnFullUser) { |
65 installer.InstallFullInstaller(false, | 103 user_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); |
66 mini_installer_constants::kStableChannelBuild); | 104 } |
105 TEST_F(MiniInstallTest, RepairFolderOnFullSys) { | |
106 sys_inst_->Repair(ChromeMiniInstaller::VERSION_FOLDER); | |
67 } | 107 } |
68 | 108 |
69 TEST_F(MiniInstallTest, | 109 // Repair registry. |
70 InstallLatestDevFullInstallerOverPreviousFullDevInstaller) { | 110 TEST_F(MiniInstallTest, RepairRegistryOnFullUser) { |
71 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 111 user_inst_->Repair(ChromeMiniInstaller::REGISTRY); |
72 installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, | 112 } |
73 mini_installer_constants::kDevChannelBuild); | 113 TEST_F(MiniInstallTest, RepairRegistryOnFullSys) { |
114 sys_inst_->Repair(ChromeMiniInstaller::REGISTRY); | |
74 } | 115 } |
75 | 116 |
76 TEST_F(MiniInstallTest, | 117 // Install standalone. |
77 InstallLatestDevFullInstallerOverPreviousFullDevInstallerSystemLevel) { | 118 TEST_F(MiniInstallTest, InstallStandaloneUser) { |
78 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | 119 user_inst_->InstallStandaloneInstaller(); |
79 installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, | |
80 mini_installer_constants::kDevChannelBuild); | |
81 } | |
82 | |
83 TEST_F(MiniInstallTest, | |
84 InstallLatestDevDiffInstallerOverPreviousFullDevInstaller) { | |
85 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
86 installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, | |
87 mini_installer_constants::kDevChannelBuild); | |
88 } | |
89 | |
90 TEST_F(MiniInstallTest, | |
91 InstallLatestDevDiffInstallerOverPreviousFullDevInstallerSystemLevel) { | |
92 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | |
93 installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, | |
94 mini_installer_constants::kDevChannelBuild); | |
95 } | |
96 | |
97 TEST_F(MiniInstallTest, | |
98 InstallLatestFullStableInstallerOverPreviousFullStableInstaller) { | |
99 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
100 installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, | |
101 mini_installer_constants::kStableChannelBuild); | |
102 } | |
103 | |
104 TEST_F(MiniInstallTest, | |
105 InstallLatestFullStableInstallerOverPreviousFullStableInstallerSystemLevel) { | |
106 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | |
107 installer.OverInstallOnFullInstaller(mini_installer_constants::kFullInstall, | |
108 mini_installer_constants::kStableChannelBuild); | |
109 } | |
110 | |
111 TEST_F(MiniInstallTest, | |
112 InstallLatestDiffStableInstallerOverPreviousFullStableInstaller) { | |
113 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
114 installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, | |
115 mini_installer_constants::kStableChannelBuild); | |
116 } | |
117 | |
118 TEST_F(MiniInstallTest, | |
119 InstallLatestDiffStableInstallerOverPreviousFullStableInstallerSystemLevel) { | |
120 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | |
121 installer.OverInstallOnFullInstaller(mini_installer_constants::kDiffInstall, | |
122 mini_installer_constants::kStableChannelBuild); | |
123 } | |
124 | |
125 TEST_F(MiniInstallTest, StandaloneInstallerTest) { | |
126 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
127 installer.InstallStandaloneInstaller(); | |
128 } | 120 } |
129 | 121 |
130 // This test doesn't make sense. Disabling for now. | 122 // This test doesn't make sense. Disabling for now. |
131 TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { | 123 TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { |
132 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 124 user_inst_->OverInstall(); |
133 installer.OverInstall(mini_installer_constants::kDevChannelBuild); | |
134 } | 125 } |
135 | 126 |
136 // Encountering issue 9593. Disabling temporarily. | 127 // Encountering issue 9593. Disabling temporarily. |
137 TEST_F(MiniInstallTest, | 128 TEST_F(MiniInstallTest, |
138 DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { | 129 DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { |
139 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 130 user_inst_->OverInstall(); |
140 installer.OverInstall(mini_installer_constants::kStableChannelBuild); | |
141 } | 131 } |
142 // Encountering issue 9593. Disabling temporarily. | 132 // Encountering issue 9593. Disabling temporarily. |
143 TEST_F(MiniInstallTest, | 133 TEST_F(MiniInstallTest, |
144 DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { | 134 DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { |
145 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 135 user_inst_->OverInstall(); |
146 installer.OverInstall(mini_installer_constants::kDevChannelBuild); | |
147 } | |
148 | |
149 // Repair testcases | |
150 | |
151 TEST_F(MiniInstallTest, RepairFolderTestOnLatestDevFullInstaller) { | |
152 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
153 installer.Repair(ChromeMiniInstaller::VERSION_FOLDER, | |
154 mini_installer_constants::kDevChannelBuild); | |
155 } | |
156 | |
157 TEST_F(MiniInstallTest, RepairFolderTestOnLatestDevFullInstallerSystemLevel) { | |
158 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | |
159 installer.Repair(ChromeMiniInstaller::VERSION_FOLDER, | |
160 mini_installer_constants::kDevChannelBuild); | |
161 } | |
162 | |
163 TEST_F(MiniInstallTest, RepairRegistryTestOnLatestDevFullInstaller) { | |
164 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | |
165 installer.Repair(ChromeMiniInstaller::REGISTRY, | |
166 mini_installer_constants::kDevChannelBuild); | |
167 } | |
168 | |
169 TEST_F(MiniInstallTest, RepairRegistryTestOnLatestDevFullInstallerSystemLevel) { | |
170 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | |
171 installer.Repair(ChromeMiniInstaller::REGISTRY, | |
172 mini_installer_constants::kDevChannelBuild); | |
173 } | 136 } |
174 #endif | 137 #endif |
175 | 138 |
176 TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtSystemLevel) { | 139 TEST_F(MiniInstallTest, InstallMiniInstallerSys) { |
177 ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); | 140 sys_inst_->Install(); |
178 installer.Install(); | |
179 } | 141 } |
180 | 142 |
181 TEST_F(MiniInstallTest, InstallLatestMiniInstallerAtUserLevel) { | 143 TEST_F(MiniInstallTest, InstallMiniInstallerUser) { |
182 ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); | 144 user_inst_->Install(); |
183 installer.Install(); | |
184 } | 145 } |
185 | 146 |
186 TEST(InstallUtilTests, MiniInstallTestValidWindowsVersion) { | 147 TEST_F(MiniInstallTest, MiniInstallTestValidWindowsVersion) { |
187 // We run the tests on all supported OSes. | 148 // We run the tests on all supported OSes. |
188 // Make sure the code agrees. | 149 // Make sure the code agrees. |
189 EXPECT_TRUE(InstallUtil::IsOSSupported()); | 150 EXPECT_TRUE(InstallUtil::IsOSSupported()); |
190 } | 151 } |
OLD | NEW |