OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #include "webrtc/base/fileutils.h" | 13 #include "webrtc/base/fileutils.h" |
12 #include "webrtc/base/gunit.h" | 14 #include "webrtc/base/gunit.h" |
13 #include "webrtc/base/optionsfile.h" | 15 #include "webrtc/base/optionsfile.h" |
14 #include "webrtc/base/pathutils.h" | 16 #include "webrtc/base/pathutils.h" |
15 | 17 |
16 namespace rtc { | 18 namespace rtc { |
17 | 19 |
18 static const std::string kTestOptionA = "test-option-a"; | 20 static const std::string kTestOptionA = "test-option-a"; |
19 static const std::string kTestOptionB = "test-option-b"; | 21 static const std::string kTestOptionB = "test-option-b"; |
20 static const std::string kTestString1 = "a string"; | 22 static const std::string kTestString1 = "a string"; |
(...skipping 23 matching lines...) Expand all Loading... |
44 | 46 |
45 ~OptionsFileTest() override { | 47 ~OptionsFileTest() override { |
46 remove(test_file_.c_str()); | 48 remove(test_file_.c_str()); |
47 } | 49 } |
48 | 50 |
49 protected: | 51 protected: |
50 void OpenStore() { | 52 void OpenStore() { |
51 store_.reset(new OptionsFile(test_file_)); | 53 store_.reset(new OptionsFile(test_file_)); |
52 } | 54 } |
53 | 55 |
54 rtc::scoped_ptr<OptionsFile> store_; | 56 std::unique_ptr<OptionsFile> store_; |
55 | 57 |
56 private: | 58 private: |
57 std::string test_file_; | 59 std::string test_file_; |
58 }; | 60 }; |
59 | 61 |
60 TEST_F(OptionsFileTest, GetSetString) { | 62 TEST_F(OptionsFileTest, GetSetString) { |
61 // Clear contents of the file on disk. | 63 // Clear contents of the file on disk. |
62 EXPECT_TRUE(store_->Save()); | 64 EXPECT_TRUE(store_->Save()); |
63 std::string out1, out2; | 65 std::string out1, out2; |
64 EXPECT_FALSE(store_->GetStringValue(kTestOptionA, &out1)); | 66 EXPECT_FALSE(store_->GetStringValue(kTestOptionA, &out1)); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 EXPECT_TRUE(store_->GetStringValue(kEmptyString, &out)); | 165 EXPECT_TRUE(store_->GetStringValue(kEmptyString, &out)); |
164 EXPECT_EQ(kTestString2, out); | 166 EXPECT_EQ(kTestString2, out); |
165 EXPECT_TRUE(store_->SetStringValue(kTestOptionB, kEmptyString)); | 167 EXPECT_TRUE(store_->SetStringValue(kTestOptionB, kEmptyString)); |
166 EXPECT_TRUE(store_->Save()); | 168 EXPECT_TRUE(store_->Save()); |
167 EXPECT_TRUE(store_->Load()); | 169 EXPECT_TRUE(store_->Load()); |
168 EXPECT_TRUE(store_->GetStringValue(kTestOptionB, &out)); | 170 EXPECT_TRUE(store_->GetStringValue(kTestOptionB, &out)); |
169 EXPECT_EQ(kEmptyString, out); | 171 EXPECT_EQ(kEmptyString, out); |
170 } | 172 } |
171 | 173 |
172 } // namespace rtc | 174 } // namespace rtc |
OLD | NEW |