value_store_change_unittest.cc 1.0 KB

1234567891011121314151617181920212223242526272829
  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
  3. // found in the LICENSE file.
  4. #include "components/value_store/value_store_change.h"
  5. #include "base/values.h"
  6. #include "testing/gtest/include/gtest/gtest.h"
  7. using base::Value;
  8. namespace value_store {
  9. TEST(ValueStoreChangeTest, ToValue) {
  10. ValueStoreChangeList changes;
  11. changes.push_back(ValueStoreChange("foo", absl::nullopt, base::Value("bar")));
  12. changes.push_back(ValueStoreChange("baz", base::Value("qux"), absl::nullopt));
  13. base::Value expected(base::Value::Type::DICTIONARY);
  14. base::Value expected_foo(base::Value::Type::DICTIONARY);
  15. base::Value expected_baz(base::Value::Type::DICTIONARY);
  16. expected_foo.SetStringKey("newValue", "bar");
  17. expected_baz.SetStringKey("oldValue", "qux");
  18. expected.SetKey("foo", std::move(expected_foo));
  19. expected.SetKey("baz", std::move(expected_baz));
  20. EXPECT_EQ(expected, ValueStoreChange::ToValue(std::move(changes)));
  21. }
  22. } // namespace value_store