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

Side by Side Diff: chrome/service/service_process_prefs_unittest.cc

Issue 10696181: Added unit test for ServiceProcessPrefs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added newline at EOF Created 8 years, 5 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
« no previous file with comments | « chrome/chrome_tests.gypi ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/service/service_process.h"
6
7 #include "base/file_util.h"
Albert Bodenhamer 2012/07/11 23:26:52 Do you need file_util or path_service? Or chrome_p
8 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h"
10 #include "chrome/common/chrome_paths.h"
11 #include "chrome/service/service_process_prefs.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 class ServiceProcessPrefsTest : public testing::Test {
16 protected:
17 virtual void SetUp() {
18 message_loop_proxy_ = base::MessageLoopProxy::current();
19
20 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
21
22 prefs_.reset(new ServiceProcessPrefs(
23 temp_dir_.path().AppendASCII("service_process_prefs.txt"),
24 message_loop_proxy_.get()));
25 }
26
27 // The path to temporary directory used to contain the test operations.
28 ScopedTempDir temp_dir_;
29 // A message loop that we can use as the file thread message loop.
30 MessageLoop message_loop_;
31 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
32 scoped_ptr<ServiceProcessPrefs> prefs_;
33 };
34
35 // Test ability to retrieve prefs
36 TEST_F(ServiceProcessPrefsTest, RetrievePrefs) {
37 prefs_->SetBoolean("testb", true);
38 prefs_->SetString("tests", "testvalue");
39 prefs_->WritePrefs();
40 MessageLoop::current()->RunAllPending();
41 prefs_->SetBoolean("testb", false); // overwrite
42 prefs_->SetString("tests", ""); // overwrite
43 prefs_->ReadPrefs();
44 bool testb;
45 prefs_->GetBoolean("testb", &testb);
46 EXPECT_EQ(testb, true);
47 std::string tests;
48 prefs_->GetString("tests", &tests);
49 EXPECT_EQ(tests, "testvalue");
50 }
51
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698