| OLD | NEW |
| 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 "chrome/browser/value_store/value_store_unittest.h" | 5 #include "chrome/browser/value_store/value_store_unittest.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 | 9 |
| 10 using content::BrowserThread; | 10 using content::BrowserThread; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 // Returns whether the read result of a storage operation has the expected | 51 // Returns whether the read result of a storage operation has the expected |
| 52 // settings. | 52 // settings. |
| 53 testing::AssertionResult SettingsEq( | 53 testing::AssertionResult SettingsEq( |
| 54 const char* _1, const char* _2, | 54 const char* _1, const char* _2, |
| 55 const DictionaryValue& expected, | 55 const DictionaryValue& expected, |
| 56 ValueStore::ReadResult actual_result) { | 56 ValueStore::ReadResult actual_result) { |
| 57 if (actual_result->HasError()) { | 57 if (actual_result->HasError()) { |
| 58 return testing::AssertionFailure() << | 58 return testing::AssertionFailure() << |
| 59 "Result has error: " << actual_result->error(); | 59 "Result has error: " << actual_result->error().message; |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string error; | 62 std::string error; |
| 63 if (!ValuesEqual(&expected, actual_result->settings().get(), &error)) { | 63 if (!ValuesEqual(&expected, &actual_result->settings(), &error)) { |
| 64 return testing::AssertionFailure() << error; | 64 return testing::AssertionFailure() << error; |
| 65 } | 65 } |
| 66 | 66 |
| 67 return testing::AssertionSuccess(); | 67 return testing::AssertionSuccess(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Returns whether the write result of a storage operation has the expected | 70 // Returns whether the write result of a storage operation has the expected |
| 71 // changes. | 71 // changes. |
| 72 testing::AssertionResult ChangesEq( | 72 testing::AssertionResult ChangesEq( |
| 73 const char* _1, const char* _2, | 73 const char* _1, const char* _2, |
| 74 const ValueStoreChangeList& expected, | 74 const ValueStoreChangeList& expected, |
| 75 ValueStore::WriteResult actual_result) { | 75 ValueStore::WriteResult actual_result) { |
| 76 if (actual_result->HasError()) { | 76 if (actual_result->HasError()) { |
| 77 return testing::AssertionFailure() << | 77 return testing::AssertionFailure() << |
| 78 "Result has error: " << actual_result->error(); | 78 "Result has error: " << actual_result->error().message; |
| 79 } | 79 } |
| 80 | 80 |
| 81 const ValueStoreChangeList& actual = actual_result->changes(); | 81 const ValueStoreChangeList& actual = actual_result->changes(); |
| 82 if (expected.size() != actual.size()) { | 82 if (expected.size() != actual.size()) { |
| 83 return testing::AssertionFailure() << | 83 return testing::AssertionFailure() << |
| 84 "Actual has wrong size, expecting " << expected.size() << | 84 "Actual has wrong size, expecting " << expected.size() << |
| 85 " but was " << actual.size(); | 85 " but was " << actual.size(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 std::map<std::string, linked_ptr<ValueStoreChange> > expected_as_map; | 88 std::map<std::string, linked_ptr<ValueStoreChange> > expected_as_map; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 470 } |
| 471 { | 471 { |
| 472 ValueStoreChangeList changes; | 472 ValueStoreChangeList changes; |
| 473 changes.push_back(ValueStoreChange(key3_, val3_->DeepCopy(), NULL)); | 473 changes.push_back(ValueStoreChange(key3_, val3_->DeepCopy(), NULL)); |
| 474 changes.push_back( | 474 changes.push_back( |
| 475 ValueStoreChange("qwerty", val3_->DeepCopy(), NULL)); | 475 ValueStoreChange("qwerty", val3_->DeepCopy(), NULL)); |
| 476 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); | 476 EXPECT_PRED_FORMAT2(ChangesEq, changes, storage_->Clear()); |
| 477 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); | 477 EXPECT_PRED_FORMAT2(ChangesEq, ValueStoreChangeList(), storage_->Clear()); |
| 478 } | 478 } |
| 479 } | 479 } |
| OLD | NEW |