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 #include <glib.h> | 5 #include <glib.h> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
10 #include "update_engine/filesystem_copier_action.h" | 10 #include "update_engine/filesystem_copier_action.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 EXPECT_FALSE(delegate.success_); | 215 EXPECT_FALSE(delegate.success_); |
216 } | 216 } |
217 | 217 |
218 TEST_F(FilesystemCopierActionTest, FullUpdateTest) { | 218 TEST_F(FilesystemCopierActionTest, FullUpdateTest) { |
219 ActionProcessor processor; | 219 ActionProcessor processor; |
220 FilesystemCopierActionTest2Delegate delegate; | 220 FilesystemCopierActionTest2Delegate delegate; |
221 | 221 |
222 processor.set_delegate(&delegate); | 222 processor.set_delegate(&delegate); |
223 | 223 |
224 ObjectFeederAction<InstallPlan> feeder_action; | 224 ObjectFeederAction<InstallPlan> feeder_action; |
225 InstallPlan install_plan(true, "", "", "", ""); | 225 InstallPlan install_plan(true, "", "", ""); |
226 feeder_action.set_obj(install_plan); | 226 feeder_action.set_obj(install_plan); |
227 FilesystemCopierAction copier_action; | 227 FilesystemCopierAction copier_action; |
228 ObjectCollectorAction<InstallPlan> collector_action; | 228 ObjectCollectorAction<InstallPlan> collector_action; |
229 | 229 |
230 BondActions(&feeder_action, &copier_action); | 230 BondActions(&feeder_action, &copier_action); |
231 BondActions(&copier_action, &collector_action); | 231 BondActions(&copier_action, &collector_action); |
232 | 232 |
233 processor.EnqueueAction(&feeder_action); | 233 processor.EnqueueAction(&feeder_action); |
234 processor.EnqueueAction(&copier_action); | 234 processor.EnqueueAction(&copier_action); |
235 processor.EnqueueAction(&collector_action); | 235 processor.EnqueueAction(&collector_action); |
236 processor.StartProcessing(); | 236 processor.StartProcessing(); |
237 EXPECT_FALSE(processor.IsRunning()); | 237 EXPECT_FALSE(processor.IsRunning()); |
238 EXPECT_TRUE(delegate.ran_); | 238 EXPECT_TRUE(delegate.ran_); |
239 EXPECT_TRUE(delegate.success_); | 239 EXPECT_TRUE(delegate.success_); |
240 } | 240 } |
241 | 241 |
242 TEST_F(FilesystemCopierActionTest, NonExistentDriveTest) { | 242 TEST_F(FilesystemCopierActionTest, NonExistentDriveTest) { |
243 ActionProcessor processor; | 243 ActionProcessor processor; |
244 FilesystemCopierActionTest2Delegate delegate; | 244 FilesystemCopierActionTest2Delegate delegate; |
245 | 245 |
246 processor.set_delegate(&delegate); | 246 processor.set_delegate(&delegate); |
247 | 247 |
248 ObjectFeederAction<InstallPlan> feeder_action; | 248 ObjectFeederAction<InstallPlan> feeder_action; |
249 InstallPlan install_plan(false, "", "", "", "/some/missing/file/path"); | 249 InstallPlan install_plan(false, "", "", "/some/missing/file/path"); |
250 feeder_action.set_obj(install_plan); | 250 feeder_action.set_obj(install_plan); |
251 FilesystemCopierAction copier_action; | 251 FilesystemCopierAction copier_action; |
252 ObjectCollectorAction<InstallPlan> collector_action; | 252 ObjectCollectorAction<InstallPlan> collector_action; |
253 | 253 |
254 BondActions(&copier_action, &collector_action); | 254 BondActions(&copier_action, &collector_action); |
255 | 255 |
256 processor.EnqueueAction(&feeder_action); | 256 processor.EnqueueAction(&feeder_action); |
257 processor.EnqueueAction(&copier_action); | 257 processor.EnqueueAction(&copier_action); |
258 processor.EnqueueAction(&collector_action); | 258 processor.EnqueueAction(&collector_action); |
259 processor.StartProcessing(); | 259 processor.StartProcessing(); |
260 EXPECT_FALSE(processor.IsRunning()); | 260 EXPECT_FALSE(processor.IsRunning()); |
261 EXPECT_TRUE(delegate.ran_); | 261 EXPECT_TRUE(delegate.ran_); |
262 EXPECT_FALSE(delegate.success_); | 262 EXPECT_FALSE(delegate.success_); |
263 } | 263 } |
264 | 264 |
265 TEST_F(FilesystemCopierActionTest, RunAsRootSkipUpdateTest) { | 265 TEST_F(FilesystemCopierActionTest, RunAsRootSkipUpdateTest) { |
266 ASSERT_EQ(0, getuid()); | 266 ASSERT_EQ(0, getuid()); |
267 DoTest(true, false); | 267 DoTest(true, false); |
268 } | 268 } |
269 | 269 |
270 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { | 270 TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) { |
271 ASSERT_EQ(0, getuid()); | 271 ASSERT_EQ(0, getuid()); |
272 DoTest(false, true); | 272 DoTest(false, true); |
273 } | 273 } |
274 | 274 |
275 } // namespace chromeos_update_engine | 275 } // namespace chromeos_update_engine |
OLD | NEW |