Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Unit test to make sure that the serialization of synchronous IPC messages | 5 // Unit test to make sure that the serialization of synchronous IPC messages |
| 6 // works. This ensures that the macros and templates were defined correctly. | 6 // works. This ensures that the macros and templates were defined correctly. |
| 7 // Doesn't test the IPC channel mechanism. | 7 // Doesn't test the IPC channel mechanism. |
| 8 | 8 |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 31 *out2 = 2; | 31 *out2 = 2; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void On_0_3(bool* out1, int* out2, std::string* out3) { | 34 void On_0_3(bool* out1, int* out2, std::string* out3) { |
| 35 *out1 = false; | 35 *out1 = false; |
| 36 *out2 = 3; | 36 *out2 = 3; |
| 37 *out3 = "0_3"; | 37 *out3 = "0_3"; |
| 38 } | 38 } |
| 39 | 39 |
| 40 void On_1_1(int in1, bool* out1) { | 40 void On_1_1(int in1, bool* out1) { |
| 41 DCHECK(in1 == 1); | 41 DCHECK_EQ(1, in1); |
| 42 *out1 = true; | 42 *out1 = true; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void On_1_2(bool in1, bool* out1, int* out2) { | 45 void On_1_2(bool in1, bool* out1, int* out2) { |
| 46 DCHECK(!in1); | 46 DCHECK(!in1); |
| 47 *out1 = true; | 47 *out1 = true; |
| 48 *out2 = 12; | 48 *out2 = 12; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void On_1_3(int in1, std::string* out1, int* out2, bool* out3) { | 51 void On_1_3(int in1, std::string* out1, int* out2, bool* out3) { |
| 52 DCHECK(in1 == 3); | 52 DCHECK_EQ(3, in1); |
| 53 *out1 = "1_3"; | 53 *out1 = "1_3"; |
| 54 *out2 = 13; | 54 *out2 = 13; |
| 55 *out3 = false; | 55 *out3 = false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void On_2_1(int in1, bool in2, bool* out1) { | 58 void On_2_1(int in1, bool in2, bool* out1) { |
| 59 DCHECK(in1 == 1 && !in2); | 59 DCHECK(in1 == 1 && !in2); |
|
Peter Kasting
2011/04/25 19:59:15
Nit: While you're here, you might want to break th
KushalP
2011/04/25 20:10:06
Should I am to do that wherever I see it? This is
| |
| 60 *out1 = true; | 60 *out1 = true; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void On_2_2(bool in1, int in2, bool* out1, int* out2) { | 63 void On_2_2(bool in1, int in2, bool* out1, int* out2) { |
| 64 DCHECK(!in1 && in2 == 2); | 64 DCHECK(!in1 && in2 == 2); |
| 65 *out1 = true; | 65 *out1 = true; |
| 66 *out2 = 22; | 66 *out2 = 22; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void On_2_3(int in1, bool in2, std::string* out1, int* out2, bool* out3) { | 69 void On_2_3(int in1, bool in2, std::string* out1, int* out2, bool* out3) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 87 void On_3_3(int in1, std::string in2, bool in3, std::string* out1, int* out2, | 87 void On_3_3(int in1, std::string in2, bool in3, std::string* out1, int* out2, |
| 88 bool* out3) { | 88 bool* out3) { |
| 89 DCHECK(in1 == 3 && in2 == "3_3" && in3); | 89 DCHECK(in1 == 3 && in2 == "3_3" && in3); |
| 90 *out1 = "3_3"; | 90 *out1 = "3_3"; |
| 91 *out2 = 33; | 91 *out2 = 33; |
| 92 *out3 = false; | 92 *out3 = false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void On_3_4(bool in1, int in2, std::string in3, int* out1, bool* out2, | 95 void On_3_4(bool in1, int in2, std::string in3, int* out1, bool* out2, |
| 96 std::string* out3, bool* out4) { | 96 std::string* out3, bool* out4) { |
| 97 DCHECK(in1 && in2 == 3 && in3 == "3_4"); | 97 DCHECK(in1 && in2 == 3 && in3 == "3_4"); |
| 98 *out1 = 34; | 98 *out1 = 34; |
| 99 *out2 = true; | 99 *out2 = true; |
| 100 *out3 = "3_4"; | 100 *out3 = "3_4"; |
| 101 *out4 = false; | 101 *out4 = false; |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool Send(IPC::Message* message) { | 104 bool Send(IPC::Message* message) { |
| 105 // gets the reply message, stash in global | 105 // gets the reply message, stash in global |
| 106 DCHECK(g_reply == NULL); | 106 DCHECK(g_reply == NULL); |
| 107 g_reply = message; | 107 g_reply = message; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 DCHECK(bool1); | 256 DCHECK(bool1); |
| 257 | 257 |
| 258 bool1 = false; | 258 bool1 = false; |
| 259 Send(new Msg_R_3_2(0, "3_2", false, 2, &bool1, &int1)); | 259 Send(new Msg_R_3_2(0, "3_2", false, 2, &bool1, &int1)); |
| 260 DCHECK(bool1 && int1 == 32); | 260 DCHECK(bool1 && int1 == 32); |
| 261 | 261 |
| 262 bool1 = true; | 262 bool1 = true; |
| 263 Send(new Msg_R_3_3(0, 3, "3_3", true, &string1, &int1, &bool1)); | 263 Send(new Msg_R_3_3(0, 3, "3_3", true, &string1, &int1, &bool1)); |
| 264 DCHECK(string1 == "3_3" && int1 == 33 && !bool1); | 264 DCHECK(string1 == "3_3" && int1 == 33 && !bool1); |
| 265 } | 265 } |
| OLD | NEW |