blob: beed519dae7c8315fa2f6a55bdb13e5262e88d67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/js_arg_list.h"
#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync {
namespace {
class JsArgListTest : public testing::Test {};
TEST_F(JsArgListTest, EmptyList) {
JsArgList arg_list;
EXPECT_TRUE(arg_list.Get().empty());
}
TEST_F(JsArgListTest, FromList) {
scoped_ptr<ListValue> list(new ListValue());
list->Append(Value::CreateBooleanValue(false));
list->Append(Value::CreateIntegerValue(5));
DictionaryValue* dict = new DictionaryValue();
list->Append(dict);
dict->SetString("foo", "bar");
dict->Set("baz", new ListValue());
JsArgList arg_list(*list);
// Make sure arg_list takes a deep copy.
scoped_ptr<ListValue> list_copy(list->DeepCopy());
list.reset();
EXPECT_TRUE(arg_list.Get().Equals(list_copy.get()));
}
TEST_F(JsArgListTest, FromVector) {
FundamentalValue bool_value(false);
FundamentalValue int_value(5);
DictionaryValue dict;
dict.SetString("foo", "bar");
dict.Set("baz", new ListValue());
std::vector<const Value*> vec;
vec.push_back(&bool_value);
vec.push_back(&int_value);
vec.push_back(&dict);
JsArgList arg_list(vec);
ListValue list;
list.Append(bool_value.DeepCopy());
list.Append(int_value.DeepCopy());
list.Append(dict.DeepCopy());
// Make sure arg_list takes a deep copy.
vec.clear();
dict.SetString("baz", "foo");
EXPECT_TRUE(arg_list.Get().Equals(&list));
}
} // namespace
} // namespace browser_sync
|