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

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

Issue 2321573002: //chrome misc: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix Win compilation Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <string> 5 #include <string>
6 6
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
11 #include "chrome/service/service_process_prefs.h" 11 #include "chrome/service/service_process_prefs.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 class ServiceProcessPrefsTest : public testing::Test { 15 class ServiceProcessPrefsTest : public testing::Test {
16 protected: 16 protected:
17 void SetUp() override { 17 void SetUp() override {
18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
19 19
20 prefs_.reset(new ServiceProcessPrefs( 20 prefs_.reset(new ServiceProcessPrefs(
21 temp_dir_.path().AppendASCII("service_process_prefs.txt"), 21 temp_dir_.GetPath().AppendASCII("service_process_prefs.txt"),
22 message_loop_.task_runner().get())); 22 message_loop_.task_runner().get()));
23 } 23 }
24 24
25 void TearDown() override { prefs_.reset(); } 25 void TearDown() override { prefs_.reset(); }
26 26
27 // The path to temporary directory used to contain the test operations. 27 // The path to temporary directory used to contain the test operations.
28 base::ScopedTempDir temp_dir_; 28 base::ScopedTempDir temp_dir_;
29 // A message loop that we can use as the file thread message loop. 29 // A message loop that we can use as the file thread message loop.
30 base::MessageLoop message_loop_; 30 base::MessageLoop message_loop_;
31 std::unique_ptr<ServiceProcessPrefs> prefs_; 31 std::unique_ptr<ServiceProcessPrefs> prefs_;
32 }; 32 };
33 33
34 // Test ability to retrieve prefs 34 // Test ability to retrieve prefs
35 TEST_F(ServiceProcessPrefsTest, RetrievePrefs) { 35 TEST_F(ServiceProcessPrefsTest, RetrievePrefs) {
36 prefs_->SetBoolean("testb", true); 36 prefs_->SetBoolean("testb", true);
37 prefs_->SetString("tests", "testvalue"); 37 prefs_->SetString("tests", "testvalue");
38 prefs_->WritePrefs(); 38 prefs_->WritePrefs();
39 base::RunLoop().RunUntilIdle(); 39 base::RunLoop().RunUntilIdle();
40 prefs_->SetBoolean("testb", false); // overwrite 40 prefs_->SetBoolean("testb", false); // overwrite
41 prefs_->SetString("tests", std::string()); // overwrite 41 prefs_->SetString("tests", std::string()); // overwrite
42 prefs_->ReadPrefs(); 42 prefs_->ReadPrefs();
43 EXPECT_EQ(prefs_->GetBoolean("testb", false), true); 43 EXPECT_EQ(prefs_->GetBoolean("testb", false), true);
44 EXPECT_EQ(prefs_->GetString("tests", std::string()), "testvalue"); 44 EXPECT_EQ(prefs_->GetString("tests", std::string()), "testvalue");
45 } 45 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/connector_settings_unittest.cc ('k') | chrome/service/service_utility_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698