OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "content/public/test/test_browser_context.h" | 9 #include "content/public/test/test_browser_context.h" |
10 #include "extensions/browser/api/extensions_api_client.h" | 10 #include "extensions/browser/api/extensions_api_client.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // Runs the storage.get() API function with the local storage, and populates | 61 // Runs the storage.get() API function with the local storage, and populates |
62 // |value| with the string result. | 62 // |value| with the string result. |
63 testing::AssertionResult RunGetFunction(const std::string& key, | 63 testing::AssertionResult RunGetFunction(const std::string& key, |
64 std::string* value) { | 64 std::string* value) { |
65 scoped_ptr<base::Value> result = RunFunctionAndReturnValue( | 65 scoped_ptr<base::Value> result = RunFunctionAndReturnValue( |
66 new StorageStorageAreaGetFunction(), | 66 new StorageStorageAreaGetFunction(), |
67 base::StringPrintf("[\"local\", \"%s\"]", key.c_str())); | 67 base::StringPrintf("[\"local\", \"%s\"]", key.c_str())); |
68 if (!result.get()) | 68 if (!result.get()) |
69 return testing::AssertionFailure() << "No result"; | 69 return testing::AssertionFailure() << "No result"; |
70 base::DictionaryValue* dict = NULL; | 70 base::DictionaryValue* dict = nullptr; |
71 if (!result->GetAsDictionary(&dict)) | 71 if (!result->GetAsDictionary(&dict)) |
72 return testing::AssertionFailure() << result << " was not a dictionary."; | 72 return testing::AssertionFailure() << result << " was not a dictionary."; |
73 if (!dict->GetString(key, value)) { | 73 if (!dict->GetString(key, value)) { |
74 return testing::AssertionFailure() << " could not retrieve a string from" | 74 return testing::AssertionFailure() << " could not retrieve a string from" |
75 << dict << " at " << key; | 75 << dict << " at " << key; |
76 } | 76 } |
77 return testing::AssertionSuccess(); | 77 return testing::AssertionSuccess(); |
78 } | 78 } |
79 | 79 |
80 MockExtensionSystemFactory< | 80 MockExtensionSystemFactory< |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 EXPECT_TRUE(leveldb_store->Get(kKey)->IsCorrupted()); | 116 EXPECT_TRUE(leveldb_store->Get(kKey)->IsCorrupted()); |
117 | 117 |
118 // Running another set should end up working (even though it will restore the | 118 // Running another set should end up working (even though it will restore the |
119 // store behind the scenes). | 119 // store behind the scenes). |
120 RunSetFunction(kKey, kValue); | 120 RunSetFunction(kKey, kValue); |
121 EXPECT_TRUE(RunGetFunction(kKey, &result)); | 121 EXPECT_TRUE(RunGetFunction(kKey, &result)); |
122 EXPECT_EQ(kValue, result); | 122 EXPECT_EQ(kValue, result); |
123 } | 123 } |
124 | 124 |
125 } // namespace extensions | 125 } // namespace extensions |
OLD | NEW |