summaryrefslogtreecommitdiffstats
path: root/chromium/sync/js/js_arg_list_unittest.cc
blob: 2a10286751bda214c553c7478042453d3b2bb124 (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
// Copyright (c) 2012 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 "sync/js/js_arg_list.h"

#include "base/memory/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace syncer {
namespace {

class JsArgListTest : public testing::Test {};

TEST_F(JsArgListTest, EmptyList) {
  JsArgList arg_list;
  EXPECT_TRUE(arg_list.Get().empty());
  EXPECT_EQ("[]", arg_list.ToString());
}

TEST_F(JsArgListTest, FromList) {
  scoped_ptr<base::ListValue> list(new base::ListValue());
  list->Append(new base::FundamentalValue(false));
  list->Append(new base::FundamentalValue(5));
  base::DictionaryValue* dict = new base::DictionaryValue();
  list->Append(dict);
  dict->SetString("foo", "bar");
  dict->Set("baz", new base::ListValue());

  scoped_ptr<base::ListValue> list_copy(list->DeepCopy());

  JsArgList arg_list(list.get());

  // |arg_list| should take over |list|'s data.
  EXPECT_TRUE(list->empty());
  EXPECT_TRUE(arg_list.Get().Equals(list_copy.get()));
}

}  // namespace
}  // namespace syncer