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

Side by Side Diff: ipc/ipc_channel_unittest.cc

Issue 940783002: Cleanup: Remove wstring methods from base::Pickle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 | « base/pickle_unittest.cc ('k') | ipc/ipc_fuzzing_tests.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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/pickle.h" 14 #include "base/pickle.h"
15 #include "base/strings/string16.h"
16 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
16 #include "ipc/ipc_message.h" 18 #include "ipc/ipc_message.h"
17 #include "ipc/ipc_test_base.h" 19 #include "ipc/ipc_test_base.h"
18 #include "ipc/ipc_test_channel_listener.h" 20 #include "ipc/ipc_test_channel_listener.h"
19 21
20 namespace { 22 namespace {
21 23
22 class IPCChannelTest : public IPCTestBase { 24 class IPCChannelTest : public IPCTestBase {
23 }; 25 };
24 26
25 // TODO(viettrungluu): Move to a separate IPCMessageTest. 27 // TODO(viettrungluu): Move to a separate IPCMessageTest.
26 TEST_F(IPCChannelTest, BasicMessageTest) { 28 TEST_F(IPCChannelTest, BasicMessageTest) {
27 int v1 = 10; 29 int v1 = 10;
28 std::string v2("foobar"); 30 std::string v2("foobar");
29 std::wstring v3(L"hello world"); 31 base::string16 v3(base::ASCIIToUTF16("hello world"));
30 32
31 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL); 33 IPC::Message m(0, 1, IPC::Message::PRIORITY_NORMAL);
32 EXPECT_TRUE(m.WriteInt(v1)); 34 EXPECT_TRUE(m.WriteInt(v1));
33 EXPECT_TRUE(m.WriteString(v2)); 35 EXPECT_TRUE(m.WriteString(v2));
34 EXPECT_TRUE(m.WriteWString(v3)); 36 EXPECT_TRUE(m.WriteString16(v3));
35 37
36 PickleIterator iter(m); 38 PickleIterator iter(m);
37 39
38 int vi; 40 int vi;
39 std::string vs; 41 std::string vs;
40 std::wstring vw; 42 base::string16 vs16;
41 43
42 EXPECT_TRUE(iter.ReadInt(&vi)); 44 EXPECT_TRUE(iter.ReadInt(&vi));
43 EXPECT_EQ(v1, vi); 45 EXPECT_EQ(v1, vi);
44 46
45 EXPECT_TRUE(iter.ReadString(&vs)); 47 EXPECT_TRUE(iter.ReadString(&vs));
46 EXPECT_EQ(v2, vs); 48 EXPECT_EQ(v2, vs);
47 49
48 EXPECT_TRUE(iter.ReadWString(&vw)); 50 EXPECT_TRUE(iter.ReadString16(&vs16));
49 EXPECT_EQ(v3, vw); 51 EXPECT_EQ(v3, vs16);
50 52
51 // should fail 53 // should fail
52 EXPECT_FALSE(iter.ReadInt(&vi)); 54 EXPECT_FALSE(iter.ReadInt(&vi));
53 EXPECT_FALSE(iter.ReadString(&vs)); 55 EXPECT_FALSE(iter.ReadString(&vs));
54 EXPECT_FALSE(iter.ReadWString(&vw)); 56 EXPECT_FALSE(iter.ReadString16(&vs16));
55 } 57 }
56 58
57 TEST_F(IPCChannelTest, ChannelTest) { 59 TEST_F(IPCChannelTest, ChannelTest) {
58 Init("GenericClient"); 60 Init("GenericClient");
59 61
60 // Set up IPC channel and start client. 62 // Set up IPC channel and start client.
61 IPC::TestChannelListener listener; 63 IPC::TestChannelListener listener;
62 CreateChannel(&listener); 64 CreateChannel(&listener);
63 listener.Init(sender()); 65 listener.Init(sender());
64 ASSERT_TRUE(ConnectChannel()); 66 ASSERT_TRUE(ConnectChannel());
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 &listener)); 195 &listener));
194 CHECK(channel->Connect()); 196 CHECK(channel->Connect());
195 listener.Init(channel.get()); 197 listener.Init(channel.get());
196 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child"); 198 IPC::TestChannelListener::SendOneMessage(channel.get(), "hello from child");
197 199
198 base::MessageLoop::current()->Run(); 200 base::MessageLoop::current()->Run();
199 return 0; 201 return 0;
200 } 202 }
201 203
202 } // namespace 204 } // namespace
OLDNEW
« no previous file with comments | « base/pickle_unittest.cc ('k') | ipc/ipc_fuzzing_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698