OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_settings_storage_unittest.h" | 5 #include "chrome/browser/extensions/extension_settings_storage_unittest.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // Need to DCHECK since ASSERT_* can't be used from destructors. | 30 // Need to DCHECK since ASSERT_* can't be used from destructors. |
31 DCHECK(called_); | 31 DCHECK(called_); |
32 } | 32 } |
33 | 33 |
34 virtual void OnSuccess(DictionaryValue* actual) OVERRIDE { | 34 virtual void OnSuccess(DictionaryValue* actual) OVERRIDE { |
35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 ASSERT_FALSE(called_) << "Callback has already been called"; | 36 ASSERT_FALSE(called_) << "Callback has already been called"; |
37 called_ = true; | 37 called_ = true; |
38 if (expected_ == NULL) { | 38 if (expected_ == NULL) { |
39 ASSERT_TRUE(actual == NULL) << "Values are different:\n" << | 39 ASSERT_TRUE(actual == NULL) << "Values are different:\n" << |
40 "Line: " << line_ << "\n" << | 40 "Line: " << line_ << "\n" << |
41 "Expected: NULL\n" << | 41 "Expected: NULL\n" << |
42 "Got: " << GetJson(actual); | 42 "Got: " << GetJson(actual); |
43 } else { | 43 } else { |
44 ASSERT_TRUE(expected_->Equals(actual)) << "Values are different:\n" << | 44 ASSERT_TRUE(expected_->Equals(actual)) << "Values are different:\n" << |
45 "Line: " << line_ << "\n" << | 45 "Line: " << line_ << "\n" << |
46 "Expected: " << GetJson(expected_) << | 46 "Expected: " << GetJson(expected_) << |
47 "Got: " << GetJson(actual); | 47 "Got: " << GetJson(actual); |
48 delete actual; | 48 delete actual; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 virtual void OnFailure(const std::string& message) OVERRIDE { | 52 virtual void OnFailure(const std::string& message) OVERRIDE { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 } | 140 } |
141 | 141 |
142 void ExtensionSettingsStorageTest::TearDown() { | 142 void ExtensionSettingsStorageTest::TearDown() { |
143 settings_ = NULL; | 143 settings_ = NULL; |
144 delete file_thread_; | 144 delete file_thread_; |
145 delete ui_thread_; | 145 delete ui_thread_; |
146 delete ui_message_loop_; | 146 delete ui_message_loop_; |
147 } | 147 } |
148 | 148 |
149 void ExtensionSettingsStorageTest::SetStorage( | 149 void ExtensionSettingsStorageTest::SetStorage( |
150 ExtensionSettingsStorage* storage) { | 150 SyncableExtensionSettingsStorage* storage) { |
151 storage_ = storage; | 151 storage_ = storage; |
152 } | 152 } |
153 | 153 |
154 TEST_P(ExtensionSettingsStorageTest, GetWhenEmpty) { | 154 TEST_P(ExtensionSettingsStorageTest, GetWhenEmpty) { |
155 storage_->Get(key1_, NEW_CALLBACK(emptyDict_.get())); | 155 storage_->Get(key1_, NEW_CALLBACK(emptyDict_.get())); |
156 storage_->Get(key2_, NEW_CALLBACK(emptyDict_.get())); | 156 storage_->Get(key2_, NEW_CALLBACK(emptyDict_.get())); |
157 storage_->Get(key3_, NEW_CALLBACK(emptyDict_.get())); | 157 storage_->Get(key3_, NEW_CALLBACK(emptyDict_.get())); |
158 storage_->Get(*emptyList_, NEW_CALLBACK(emptyDict_.get())); | 158 storage_->Get(*emptyList_, NEW_CALLBACK(emptyDict_.get())); |
159 storage_->Get(*list1_, NEW_CALLBACK(emptyDict_.get())); | 159 storage_->Get(*list1_, NEW_CALLBACK(emptyDict_.get())); |
160 storage_->Get(*list123_, NEW_CALLBACK(emptyDict_.get())); | 160 storage_->Get(*list123_, NEW_CALLBACK(emptyDict_.get())); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 storage_->Set(outer_dict, NEW_CALLBACK(&outer_dict)); | 329 storage_->Set(outer_dict, NEW_CALLBACK(&outer_dict)); |
330 MessageLoop::current()->RunAllPending(); | 330 MessageLoop::current()->RunAllPending(); |
331 | 331 |
332 storage_->Get("foo", NEW_CALLBACK(&outer_dict)); | 332 storage_->Get("foo", NEW_CALLBACK(&outer_dict)); |
333 MessageLoop::current()->RunAllPending(); | 333 MessageLoop::current()->RunAllPending(); |
334 | 334 |
335 storage_->Get("foo.bar", NEW_CALLBACK(emptyDict_.get())); | 335 storage_->Get("foo.bar", NEW_CALLBACK(emptyDict_.get())); |
336 MessageLoop::current()->RunAllPending(); | 336 MessageLoop::current()->RunAllPending(); |
337 } | 337 } |
OLD | NEW |