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

Side by Side Diff: chrome/browser/value_store/value_store_frontend_unittest.cc

Issue 16703018: Rewrite scoped_ptr<T>(NULL) to use the default ctor in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/browser/value_store/value_store_frontend.h" 10 #include "chrome/browser/value_store/value_store_frontend.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 scoped_ptr<ValueStoreFrontend> storage_; 62 scoped_ptr<ValueStoreFrontend> storage_;
63 base::ScopedTempDir temp_dir_; 63 base::ScopedTempDir temp_dir_;
64 base::FilePath db_path_; 64 base::FilePath db_path_;
65 base::MessageLoop message_loop_; 65 base::MessageLoop message_loop_;
66 content::TestBrowserThread ui_thread_; 66 content::TestBrowserThread ui_thread_;
67 content::TestBrowserThread file_thread_; 67 content::TestBrowserThread file_thread_;
68 }; 68 };
69 69
70 TEST_F(ValueStoreFrontendTest, GetExistingData) { 70 TEST_F(ValueStoreFrontendTest, GetExistingData) {
71 scoped_ptr<base::Value> value(NULL); 71 scoped_ptr<base::Value> value;
72 ASSERT_FALSE(Get("key0", &value)); 72 ASSERT_FALSE(Get("key0", &value));
73 73
74 // Test existing keys in the DB. 74 // Test existing keys in the DB.
75 { 75 {
76 ASSERT_TRUE(Get("key1", &value)); 76 ASSERT_TRUE(Get("key1", &value));
77 std::string result; 77 std::string result;
78 ASSERT_TRUE(value->GetAsString(&result)); 78 ASSERT_TRUE(value->GetAsString(&result));
79 EXPECT_EQ("value1", result); 79 EXPECT_EQ("value1", result);
80 } 80 }
81 81
82 { 82 {
83 ASSERT_TRUE(Get("key2", &value)); 83 ASSERT_TRUE(Get("key2", &value));
84 int result; 84 int result;
85 ASSERT_TRUE(value->GetAsInteger(&result)); 85 ASSERT_TRUE(value->GetAsInteger(&result));
86 EXPECT_EQ(2, result); 86 EXPECT_EQ(2, result);
87 } 87 }
88 } 88 }
89 89
90 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) { 90 TEST_F(ValueStoreFrontendTest, ChangesPersistAfterReload) {
91 storage_->Set("key0", 91 storage_->Set("key0",
92 scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0))); 92 scoped_ptr<base::Value>(base::Value::CreateIntegerValue(0)));
93 storage_->Set("key1", 93 storage_->Set("key1",
94 scoped_ptr<base::Value>(base::Value::CreateStringValue("new1"))); 94 scoped_ptr<base::Value>(base::Value::CreateStringValue("new1")));
95 storage_->Remove("key2"); 95 storage_->Remove("key2");
96 96
97 // Reload the DB and test our changes. 97 // Reload the DB and test our changes.
98 ResetStorage(); 98 ResetStorage();
99 99
100 scoped_ptr<base::Value> value(NULL); 100 scoped_ptr<base::Value> value;
101 { 101 {
102 ASSERT_TRUE(Get("key0", &value)); 102 ASSERT_TRUE(Get("key0", &value));
103 int result; 103 int result;
104 ASSERT_TRUE(value->GetAsInteger(&result)); 104 ASSERT_TRUE(value->GetAsInteger(&result));
105 EXPECT_EQ(0, result); 105 EXPECT_EQ(0, result);
106 } 106 }
107 107
108 { 108 {
109 ASSERT_TRUE(Get("key1", &value)); 109 ASSERT_TRUE(Get("key1", &value));
110 std::string result; 110 std::string result;
111 ASSERT_TRUE(value->GetAsString(&result)); 111 ASSERT_TRUE(value->GetAsString(&result));
112 EXPECT_EQ("new1", result); 112 EXPECT_EQ("new1", result);
113 } 113 }
114 114
115 ASSERT_FALSE(Get("key2", &value)); 115 ASSERT_FALSE(Get("key2", &value));
116 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698