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