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

Side by Side Diff: ipc/ipc_message_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698