Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: tools/json_schema_compiler/test/objects_unittest.cc

Issue 1811413002: [Extensions] Update generated code to support move operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/json_schema_compiler/test/objects_movable.idl ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "tools/json_schema_compiler/test/objects.h"
6
7 #include <stddef.h> 5 #include <stddef.h>
8 6
9 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "tools/json_schema_compiler/test/objects.h"
10 #include "tools/json_schema_compiler/test/objects_movable.h"
11 11
12 using namespace test::api::objects; 12 using namespace test::api::objects;
13 using namespace test::api::objects_movable;
13 14
14 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) { 15 TEST(JsonSchemaCompilerObjectsTest, ObjectParamParamsCreate) {
15 { 16 {
16 scoped_ptr<base::ListValue> strings(new base::ListValue()); 17 scoped_ptr<base::ListValue> strings(new base::ListValue());
17 strings->Append(new base::StringValue("one")); 18 strings->Append(new base::StringValue("one"));
18 strings->Append(new base::StringValue("two")); 19 strings->Append(new base::StringValue("two"));
19 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue()); 20 scoped_ptr<base::DictionaryValue> info_value(new base::DictionaryValue());
20 info_value->Set("strings", strings.release()); 21 info_value->Set("strings", strings.release());
21 info_value->Set("integer", new base::FundamentalValue(5)); 22 info_value->Set("integer", new base::FundamentalValue(5));
22 info_value->Set("boolean", new base::FundamentalValue(true)); 23 info_value->Set("boolean", new base::FundamentalValue(true));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 OnObjectFired::SomeObject object; 65 OnObjectFired::SomeObject object;
65 object.state = FIRST_STATE_BAR; 66 object.state = FIRST_STATE_BAR;
66 scoped_ptr<base::ListValue> results(OnObjectFired::Create(object)); 67 scoped_ptr<base::ListValue> results(OnObjectFired::Create(object));
67 68
68 base::DictionaryValue expected; 69 base::DictionaryValue expected;
69 expected.SetString("state", "bar"); 70 expected.SetString("state", "bar");
70 base::DictionaryValue* result = NULL; 71 base::DictionaryValue* result = NULL;
71 ASSERT_TRUE(results->GetDictionary(0, &result)); 72 ASSERT_TRUE(results->GetDictionary(0, &result));
72 ASSERT_TRUE(result->Equals(&expected)); 73 ASSERT_TRUE(result->Equals(&expected));
73 } 74 }
75 TEST(JsonSchemaCompilerMovableObjectsTest, MovableObjectsTest) {
76 std::vector<MovablePod> pods;
77 {
78 MovablePod pod;
79 pod.foo = FOO_BAR;
80 pod.str = "str1";
81 pod.num = 42;
82 pod.b = true;
83 pods.push_back(std::move(pod));
84 }
85 {
86 MovablePod pod;
87 pod.foo = FOO_BAZ;
88 pod.str = "str2";
89 pod.num = 45;
90 pod.b = false;
91 pods.push_back(std::move(pod));
92 }
93 MovableParent parent;
94 parent.pods = std::move(pods);
95 parent.strs.push_back("pstr");
96
97 MovableParent parent2(std::move(parent));
98 ASSERT_EQ(2u, parent2.pods.size());
99 EXPECT_EQ(FOO_BAR, parent2.pods[0].foo);
100 EXPECT_EQ("str1", parent2.pods[0].str);
101 EXPECT_EQ(42, parent2.pods[0].num);
102 EXPECT_TRUE(parent2.pods[0].b);
103 EXPECT_EQ(FOO_BAZ, parent2.pods[1].foo);
104 EXPECT_EQ("str2", parent2.pods[1].str);
105 EXPECT_EQ(45, parent2.pods[1].num);
106 EXPECT_FALSE(parent2.pods[1].b);
107 ASSERT_EQ(1u, parent2.strs.size());
108 EXPECT_EQ("pstr", parent2.strs[0]);
109 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/test/objects_movable.idl ('k') | tools/json_schema_compiler/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698