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

Side by Side Diff: ipc/ipc_message_unittest.cc

Issue 2838893002: Remove base::ListValue::Set(size_t, base::Value*) (Closed)
Patch Set: Fix Compilation Error Created 3 years, 8 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 | « ios/chrome/browser/notification_promo_unittest.cc ('k') | ipc/ipc_message_utils.cc » ('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 "ipc/ipc_message.h" 5 #include "ipc/ipc_message.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 EXPECT_EQ(v3, vs16); 59 EXPECT_EQ(v3, vs16);
60 60
61 // should fail 61 // should fail
62 EXPECT_FALSE(iter.ReadInt(&vi)); 62 EXPECT_FALSE(iter.ReadInt(&vi));
63 EXPECT_FALSE(iter.ReadString(&vs)); 63 EXPECT_FALSE(iter.ReadString(&vs));
64 EXPECT_FALSE(iter.ReadString16(&vs16)); 64 EXPECT_FALSE(iter.ReadString16(&vs16));
65 } 65 }
66 66
67 TEST(IPCMessageTest, ListValue) { 67 TEST(IPCMessageTest, ListValue) {
68 base::ListValue input; 68 base::ListValue input;
69 input.Set(0, new base::Value(42.42)); 69 input.AppendDouble(42.42);
70 input.Set(1, new base::Value("forty")); 70 input.AppendString("forty");
71 input.Set(2, base::MakeUnique<base::Value>()); 71 input.Append(base::MakeUnique<base::Value>());
72 72
73 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 73 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
74 IPC::WriteParam(&msg, input); 74 IPC::WriteParam(&msg, input);
75 75
76 base::ListValue output; 76 base::ListValue output;
77 base::PickleIterator iter(msg); 77 base::PickleIterator iter(msg);
78 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 78 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
79 79
80 EXPECT_TRUE(input.Equals(&output)); 80 EXPECT_TRUE(input.Equals(&output));
81 81
82 // Also test the corrupt case. 82 // Also test the corrupt case.
83 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); 83 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
84 bad_msg.WriteInt(99); 84 bad_msg.WriteInt(99);
85 iter = base::PickleIterator(bad_msg); 85 iter = base::PickleIterator(bad_msg);
86 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); 86 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
87 } 87 }
88 88
89 TEST(IPCMessageTest, DictionaryValue) { 89 TEST(IPCMessageTest, DictionaryValue) {
90 base::DictionaryValue input; 90 base::DictionaryValue input;
91 input.Set("null", base::MakeUnique<base::Value>()); 91 input.Set("null", base::MakeUnique<base::Value>());
92 input.Set("bool", new base::Value(true)); 92 input.Set("bool", new base::Value(true));
93 input.Set("int", new base::Value(42)); 93 input.Set("int", new base::Value(42));
94 input.SetWithoutPathExpansion("int.with.dot", new base::Value(43)); 94 input.SetWithoutPathExpansion("int.with.dot", new base::Value(43));
95 95
96 std::unique_ptr<base::DictionaryValue> subdict(new base::DictionaryValue()); 96 std::unique_ptr<base::DictionaryValue> subdict(new base::DictionaryValue());
97 subdict->Set("str", new base::Value("forty two")); 97 subdict->Set("str", new base::Value("forty two"));
98 subdict->Set("bool", new base::Value(false)); 98 subdict->Set("bool", new base::Value(false));
99 99
100 std::unique_ptr<base::ListValue> sublist(new base::ListValue()); 100 std::unique_ptr<base::ListValue> sublist(new base::ListValue());
101 sublist->Set(0, new base::Value(42.42)); 101 sublist->AppendDouble(42.42);
102 sublist->Set(1, new base::Value("forty")); 102 sublist->AppendString("forty");
103 sublist->Set(2, new base::Value("two")); 103 sublist->AppendString("two");
104 subdict->Set("list", sublist.release()); 104 subdict->Set("list", sublist.release());
105 105
106 input.Set("dict", subdict.release()); 106 input.Set("dict", subdict.release());
107 107
108 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 108 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
109 IPC::WriteParam(&msg, input); 109 IPC::WriteParam(&msg, input);
110 110
111 base::DictionaryValue output; 111 base::DictionaryValue output;
112 base::PickleIterator iter(msg); 112 base::PickleIterator iter(msg);
113 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 113 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 /* TODO: handle sync IPCs 271 /* TODO: handle sync IPCs
272 TEST_F(IPCMessageParameterTest, Sync) { 272 TEST_F(IPCMessageParameterTest, Sync) {
273 std::string output; 273 std::string output;
274 TestMsgClassIS message(42, &output); 274 TestMsgClassIS message(42, &output);
275 EXPECT_TRUE(OnMessageReceived(message)); 275 EXPECT_TRUE(OnMessageReceived(message));
276 EXPECT_TRUE(called_); 276 EXPECT_TRUE(called_);
277 EXPECT_EQ(output, std::string("out")); 277 EXPECT_EQ(output, std::string("out"));
278 }*/ 278 }*/
279 279
280 } // namespace IPC 280 } // namespace IPC
OLDNEW
« no previous file with comments | « ios/chrome/browser/notification_promo_unittest.cc ('k') | ipc/ipc_message_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698