Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(736)

Side by Side Diff: update_attempter_unittest.cc

Issue 3404015: AU: move AU completed marker from /tmp to /var/run since /var/run is root-only. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « update_attempter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <base/file_util.h> 5 #include <base/file_util.h>
6 #include <gtest/gtest.h> 6 #include <gtest/gtest.h>
7 7
8 #include "update_engine/action_mock.h" 8 #include "update_engine/action_mock.h"
9 #include "update_engine/action_processor_mock.h" 9 #include "update_engine/action_processor_mock.h"
10 #include "update_engine/filesystem_copier_action.h" 10 #include "update_engine/filesystem_copier_action.h"
11 #include "update_engine/postinstall_runner_action.h" 11 #include "update_engine/postinstall_runner_action.h"
12 #include "update_engine/set_bootable_flag_action.h" 12 #include "update_engine/set_bootable_flag_action.h"
13 #include "update_engine/update_attempter.h" 13 #include "update_engine/update_attempter.h"
14 14
15 using std::string; 15 using std::string;
16 using testing::InSequence; 16 using testing::InSequence;
17 using testing::Property; 17 using testing::Property;
18 using testing::Return; 18 using testing::Return;
19 19
20 namespace chromeos_update_engine { 20 namespace chromeos_update_engine {
21 21
22 // Test a subclass rather than the main class directly so that we can mock out 22 // Test a subclass rather than the main class directly so that we can mock out
23 // methods within the class. There're explicit unit test for the mocked out 23 // methods within the class. There're explicit unit tests for the mocked out
24 // methods. 24 // methods.
25 class UpdateAttempterUnderTest : public UpdateAttempter { 25 class UpdateAttempterUnderTest : public UpdateAttempter {
26 public: 26 public:
27 UpdateAttempterUnderTest() 27 UpdateAttempterUnderTest()
28 : UpdateAttempter(NULL, NULL) {} 28 : UpdateAttempter(NULL, NULL) {}
29 }; 29 };
30 30
31 class UpdateAttempterTest : public ::testing::Test { 31 class UpdateAttempterTest : public ::testing::Test {
32 protected: 32 protected:
33 virtual void SetUp() { 33 virtual void SetUp() {
(...skipping 11 matching lines...) Expand all
45 EXPECT_EQ("0.0.0.0", attempter_.new_version_); 45 EXPECT_EQ("0.0.0.0", attempter_.new_version_);
46 EXPECT_EQ(0, attempter_.new_size_); 46 EXPECT_EQ(0, attempter_.new_size_);
47 processor_ = new ActionProcessorMock(); 47 processor_ = new ActionProcessorMock();
48 attempter_.processor_.reset(processor_); // Transfers ownership. 48 attempter_.processor_.reset(processor_); // Transfers ownership.
49 } 49 }
50 50
51 UpdateAttempterUnderTest attempter_; 51 UpdateAttempterUnderTest attempter_;
52 ActionProcessorMock* processor_; 52 ActionProcessorMock* processor_;
53 }; 53 };
54 54
55 TEST_F(UpdateAttempterTest, ConstructWithUpdatedMarkerTest) { 55 TEST_F(UpdateAttempterTest, RunAsRootConstructWithUpdatedMarkerTest) {
56 extern const char* kUpdateCompletedMarker; 56 extern const char* kUpdateCompletedMarker;
57 const FilePath kMarker(kUpdateCompletedMarker); 57 const FilePath kMarker(kUpdateCompletedMarker);
58 EXPECT_EQ(0, file_util::WriteFile(kMarker, "", 0)); 58 EXPECT_EQ(0, file_util::WriteFile(kMarker, "", 0));
59 UpdateAttempterUnderTest attempter; 59 UpdateAttempterUnderTest attempter;
60 EXPECT_EQ(UPDATE_STATUS_UPDATED_NEED_REBOOT, attempter.status()); 60 EXPECT_EQ(UPDATE_STATUS_UPDATED_NEED_REBOOT, attempter.status());
61 EXPECT_TRUE(file_util::Delete(kMarker, false)); 61 EXPECT_TRUE(file_util::Delete(kMarker, false));
62 } 62 }
63 63
64 TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) { 64 TEST_F(UpdateAttempterTest, GetErrorCodeForActionTest) {
65 extern ActionExitCode GetErrorCodeForAction(AbstractAction* action, 65 extern ActionExitCode GetErrorCodeForAction(AbstractAction* action,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 EXPECT_EQ(attempter_.response_handler_action_.get(), 147 EXPECT_EQ(attempter_.response_handler_action_.get(),
148 attempter_.actions_[1].get()); 148 attempter_.actions_[1].get());
149 DownloadAction* download_action = 149 DownloadAction* download_action =
150 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get()); 150 dynamic_cast<DownloadAction*>(attempter_.actions_[5].get());
151 ASSERT_TRUE(download_action != NULL); 151 ASSERT_TRUE(download_action != NULL);
152 EXPECT_EQ(&attempter_, download_action->delegate()); 152 EXPECT_EQ(&attempter_, download_action->delegate());
153 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status()); 153 EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status());
154 } 154 }
155 155
156 } // namespace chromeos_update_engine 156 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « update_attempter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698