| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
| 11 #include "mojo/apps/js/mojo_runner_delegate.h" | 11 #include "mojo/apps/js/mojo_runner_delegate.h" |
| 12 #include "mojo/apps/js/test/js_to_cpp.mojom.h" | 12 #include "mojo/apps/js/test/js_to_cpp.mojom.h" |
| 13 #include "mojo/common/common_type_converters.h" | 13 #include "mojo/common/common_type_converters.h" |
| 14 #include "mojo/common/test/test_utils.h" | 14 #include "mojo/common/test/test_utils.h" |
| 15 #include "mojo/public/cpp/bindings/allocation_scope.h" | |
| 16 #include "mojo/public/cpp/environment/environment.h" | 15 #include "mojo/public/cpp/environment/environment.h" |
| 17 #include "mojo/public/cpp/system/core.h" | 16 #include "mojo/public/cpp/system/core.h" |
| 18 #include "mojo/public/cpp/system/macros.h" | 17 #include "mojo/public/cpp/system/macros.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 namespace mojo { | 20 namespace mojo { |
| 22 namespace js { | 21 namespace js { |
| 23 | 22 |
| 24 // Global value updated by some checks to prevent compilers from optimizing | 23 // Global value updated by some checks to prevent compilers from optimizing |
| 25 // reads out of existence. | 24 // reads out of existence. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 81 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 83 MojoResult result = MojoReadMessage( | 82 MojoResult result = MojoReadMessage( |
| 84 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); | 83 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); |
| 85 EXPECT_EQ(MOJO_RESULT_OK, result); | 84 EXPECT_EQ(MOJO_RESULT_OK, result); |
| 86 EXPECT_EQ(64u, buffer_size); | 85 EXPECT_EQ(64u, buffer_size); |
| 87 for (int i = 0; i < 64; ++i) { | 86 for (int i = 0; i < 64; ++i) { |
| 88 EXPECT_EQ(255 - i, buffer[i]); | 87 EXPECT_EQ(255 - i, buffer[i]); |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| 92 // NOTE: Callers will need to have established an AllocationScope, or you're | 91 js_to_cpp::EchoArgsPtr BuildSampleEchoArgs() { |
| 93 // gonna have a bad time. | 92 js_to_cpp::EchoArgsPtr args(js_to_cpp::EchoArgs::New()); |
| 94 js_to_cpp::EchoArgs BuildSampleEchoArgs() { | 93 args->si64 = kExpectedInt64Value; |
| 95 js_to_cpp::EchoArgs::Builder builder; | 94 args->si32 = kExpectedInt32Value; |
| 96 builder.set_si64(kExpectedInt64Value); | 95 args->si16 = kExpectedInt16Value; |
| 97 builder.set_si32(kExpectedInt32Value); | 96 args->si8 = kExpectedInt8Value; |
| 98 builder.set_si16(kExpectedInt16Value); | 97 args->ui64 = kExpectedUInt64Value; |
| 99 builder.set_si8(kExpectedInt8Value); | 98 args->ui32 = kExpectedUInt32Value; |
| 100 builder.set_ui64(kExpectedUInt64Value); | 99 args->ui16 = kExpectedUInt16Value; |
| 101 builder.set_ui32(kExpectedUInt32Value); | 100 args->ui8 = kExpectedUInt8Value; |
| 102 builder.set_ui16(kExpectedUInt16Value); | 101 args->float_val = kExpectedFloatVal; |
| 103 builder.set_ui8(kExpectedUInt8Value); | 102 args->float_inf = kExpectedFloatInf; |
| 104 builder.set_float_val(kExpectedFloatVal); | 103 args->float_nan = kExpectedFloatNan; |
| 105 builder.set_float_inf(kExpectedFloatInf); | 104 args->double_val = kExpectedDoubleVal; |
| 106 builder.set_float_nan(kExpectedFloatNan); | 105 args->double_inf = kExpectedDoubleInf; |
| 107 builder.set_double_val(kExpectedDoubleVal); | 106 args->double_nan = kExpectedDoubleNan; |
| 108 builder.set_double_inf(kExpectedDoubleInf); | 107 args->name = "coming"; |
| 109 builder.set_double_nan(kExpectedDoubleNan); | 108 Array<String> string_array(3); |
| 110 builder.set_name("coming"); | |
| 111 mojo::Array<mojo::String>::Builder string_array(3); | |
| 112 string_array[0] = "one"; | 109 string_array[0] = "one"; |
| 113 string_array[1] = "two"; | 110 string_array[1] = "two"; |
| 114 string_array[2] = "three"; | 111 string_array[2] = "three"; |
| 115 builder.set_string_array(string_array.Finish()); | 112 args->string_array = string_array.Pass(); |
| 116 return builder.Finish(); | 113 return args.Pass(); |
| 117 } | 114 } |
| 118 | 115 |
| 119 void CheckSampleEchoArgs(const js_to_cpp::EchoArgs& arg) { | 116 void CheckSampleEchoArgs(const js_to_cpp::EchoArgs& arg) { |
| 120 EXPECT_EQ(kExpectedInt64Value, arg.si64()); | 117 EXPECT_EQ(kExpectedInt64Value, arg.si64); |
| 121 EXPECT_EQ(kExpectedInt32Value, arg.si32()); | 118 EXPECT_EQ(kExpectedInt32Value, arg.si32); |
| 122 EXPECT_EQ(kExpectedInt16Value, arg.si16()); | 119 EXPECT_EQ(kExpectedInt16Value, arg.si16); |
| 123 EXPECT_EQ(kExpectedInt8Value, arg.si8()); | 120 EXPECT_EQ(kExpectedInt8Value, arg.si8); |
| 124 EXPECT_EQ(kExpectedUInt64Value, arg.ui64()); | 121 EXPECT_EQ(kExpectedUInt64Value, arg.ui64); |
| 125 EXPECT_EQ(kExpectedUInt32Value, arg.ui32()); | 122 EXPECT_EQ(kExpectedUInt32Value, arg.ui32); |
| 126 EXPECT_EQ(kExpectedUInt16Value, arg.ui16()); | 123 EXPECT_EQ(kExpectedUInt16Value, arg.ui16); |
| 127 EXPECT_EQ(kExpectedUInt8Value, arg.ui8()); | 124 EXPECT_EQ(kExpectedUInt8Value, arg.ui8); |
| 128 EXPECT_EQ(kExpectedFloatVal, arg.float_val()); | 125 EXPECT_EQ(kExpectedFloatVal, arg.float_val); |
| 129 EXPECT_EQ(kExpectedFloatInf, arg.float_inf()); | 126 EXPECT_EQ(kExpectedFloatInf, arg.float_inf); |
| 130 EXPECT_NAN(arg.float_nan()); | 127 EXPECT_NAN(arg.float_nan); |
| 131 EXPECT_EQ(kExpectedDoubleVal, arg.double_val()); | 128 EXPECT_EQ(kExpectedDoubleVal, arg.double_val); |
| 132 EXPECT_EQ(kExpectedDoubleInf, arg.double_inf()); | 129 EXPECT_EQ(kExpectedDoubleInf, arg.double_inf); |
| 133 EXPECT_NAN(arg.double_nan()); | 130 EXPECT_NAN(arg.double_nan); |
| 134 EXPECT_EQ(std::string("coming"), arg.name().To<std::string>()); | 131 EXPECT_EQ(std::string("coming"), arg.name.get()); |
| 135 EXPECT_EQ(std::string("one"), arg.string_array()[0].To<std::string>()); | 132 EXPECT_EQ(std::string("one"), arg.string_array[0].get()); |
| 136 EXPECT_EQ(std::string("two"), arg.string_array()[1].To<std::string>()); | 133 EXPECT_EQ(std::string("two"), arg.string_array[1].get()); |
| 137 EXPECT_EQ(std::string("three"), arg.string_array()[2].To<std::string>()); | 134 EXPECT_EQ(std::string("three"), arg.string_array[2].get()); |
| 138 CheckDataPipe(arg.data_handle().get().value()); | 135 CheckDataPipe(arg.data_handle.get().value()); |
| 139 CheckMessagePipe(arg.message_handle().get().value()); | 136 CheckMessagePipe(arg.message_handle.get().value()); |
| 140 } | 137 } |
| 141 | 138 |
| 142 void CheckSampleEchoArgsList(const js_to_cpp::EchoArgsList& list) { | 139 void CheckSampleEchoArgsList(const js_to_cpp::EchoArgsListPtr& list) { |
| 143 if (list.is_null()) | 140 if (list.is_null()) |
| 144 return; | 141 return; |
| 145 CheckSampleEchoArgs(list.item()); | 142 CheckSampleEchoArgs(*list->item); |
| 146 CheckSampleEchoArgsList(list.next()); | 143 CheckSampleEchoArgsList(list->next); |
| 147 } | 144 } |
| 148 | 145 |
| 149 // More forgiving checks are needed in the face of potentially corrupt | 146 // More forgiving checks are needed in the face of potentially corrupt |
| 150 // messages. The values don't matter so long as all accesses are within | 147 // messages. The values don't matter so long as all accesses are within |
| 151 // bounds. | 148 // bounds. |
| 152 void CheckCorruptedString(const mojo::String& arg) { | 149 void CheckCorruptedString(const String& arg) { |
| 153 if (arg.is_null()) | 150 if (arg.is_null()) |
| 154 return; | 151 return; |
| 155 for (size_t i = 0; i < arg.size(); ++i) | 152 for (size_t i = 0; i < arg.size(); ++i) |
| 156 g_waste_accumulator += arg[i]; | 153 g_waste_accumulator += arg[i]; |
| 157 } | 154 } |
| 158 | 155 |
| 159 void CheckCorruptedStringArray(const mojo::Array<mojo::String>& string_array) { | 156 void CheckCorruptedStringArray(const Array<String>& string_array) { |
| 160 if (string_array.is_null()) | 157 if (string_array.is_null()) |
| 161 return; | 158 return; |
| 162 for (size_t i = 0; i < string_array.size(); ++i) | 159 for (size_t i = 0; i < string_array.size(); ++i) |
| 163 CheckCorruptedString(string_array[i]); | 160 CheckCorruptedString(string_array[i]); |
| 164 } | 161 } |
| 165 | 162 |
| 166 void CheckCorruptedDataPipe(MojoHandle data_pipe_handle) { | 163 void CheckCorruptedDataPipe(MojoHandle data_pipe_handle) { |
| 167 unsigned char buffer[100]; | 164 unsigned char buffer[100]; |
| 168 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 165 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 169 MojoResult result = MojoReadData( | 166 MojoResult result = MojoReadData( |
| 170 data_pipe_handle, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE); | 167 data_pipe_handle, buffer, &buffer_size, MOJO_READ_DATA_FLAG_NONE); |
| 171 if (result != MOJO_RESULT_OK) | 168 if (result != MOJO_RESULT_OK) |
| 172 return; | 169 return; |
| 173 for (uint32_t i = 0; i < buffer_size; ++i) | 170 for (uint32_t i = 0; i < buffer_size; ++i) |
| 174 g_waste_accumulator += buffer[i]; | 171 g_waste_accumulator += buffer[i]; |
| 175 } | 172 } |
| 176 | 173 |
| 177 void CheckCorruptedMessagePipe(MojoHandle message_pipe_handle) { | 174 void CheckCorruptedMessagePipe(MojoHandle message_pipe_handle) { |
| 178 unsigned char buffer[100]; | 175 unsigned char buffer[100]; |
| 179 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); | 176 uint32_t buffer_size = static_cast<uint32_t>(sizeof(buffer)); |
| 180 MojoResult result = MojoReadMessage( | 177 MojoResult result = MojoReadMessage( |
| 181 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); | 178 message_pipe_handle, buffer, &buffer_size, 0, 0, 0); |
| 182 if (result != MOJO_RESULT_OK) | 179 if (result != MOJO_RESULT_OK) |
| 183 return; | 180 return; |
| 184 for (uint32_t i = 0; i < buffer_size; ++i) | 181 for (uint32_t i = 0; i < buffer_size; ++i) |
| 185 g_waste_accumulator += buffer[i]; | 182 g_waste_accumulator += buffer[i]; |
| 186 } | 183 } |
| 187 | 184 |
| 188 void CheckCorruptedEchoArgs(const js_to_cpp::EchoArgs& arg) { | 185 void CheckCorruptedEchoArgs(const js_to_cpp::EchoArgsPtr& arg) { |
| 189 if (arg.is_null()) | 186 if (arg.is_null()) |
| 190 return; | 187 return; |
| 191 CheckCorruptedString(arg.name()); | 188 CheckCorruptedString(arg->name); |
| 192 CheckCorruptedStringArray(arg.string_array()); | 189 CheckCorruptedStringArray(arg->string_array); |
| 193 if (arg.data_handle().is_valid()) | 190 if (arg->data_handle.is_valid()) |
| 194 CheckCorruptedDataPipe(arg.data_handle().get().value()); | 191 CheckCorruptedDataPipe(arg->data_handle.get().value()); |
| 195 if (arg.message_handle().is_valid()) | 192 if (arg->message_handle.is_valid()) |
| 196 CheckCorruptedMessagePipe(arg.message_handle().get().value()); | 193 CheckCorruptedMessagePipe(arg->message_handle.get().value()); |
| 197 } | 194 } |
| 198 | 195 |
| 199 void CheckCorruptedEchoArgsList(const js_to_cpp::EchoArgsList& list) { | 196 void CheckCorruptedEchoArgsList(const js_to_cpp::EchoArgsListPtr& list) { |
| 200 if (list.is_null()) | 197 if (list.is_null()) |
| 201 return; | 198 return; |
| 202 CheckCorruptedEchoArgs(list.item()); | 199 CheckCorruptedEchoArgs(list->item); |
| 203 CheckCorruptedEchoArgsList(list.next()); | 200 CheckCorruptedEchoArgsList(list->next); |
| 204 } | 201 } |
| 205 | 202 |
| 206 // Base Provider implementation class. It's expected that tests subclass and | 203 // Base Provider implementation class. It's expected that tests subclass and |
| 207 // override the appropriate Provider functions. When test is done quit the | 204 // override the appropriate Provider functions. When test is done quit the |
| 208 // run_loop(). | 205 // run_loop(). |
| 209 class CppSideConnection : public js_to_cpp::CppSide { | 206 class CppSideConnection : public js_to_cpp::CppSide { |
| 210 public: | 207 public: |
| 211 CppSideConnection() : | 208 CppSideConnection() : |
| 212 run_loop_(NULL), | 209 run_loop_(NULL), |
| 213 js_side_(NULL), | 210 js_side_(NULL), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 227 } | 224 } |
| 228 | 225 |
| 229 virtual void TestFinished() OVERRIDE { | 226 virtual void TestFinished() OVERRIDE { |
| 230 NOTREACHED(); | 227 NOTREACHED(); |
| 231 } | 228 } |
| 232 | 229 |
| 233 virtual void PingResponse() OVERRIDE { | 230 virtual void PingResponse() OVERRIDE { |
| 234 mishandled_messages_ += 1; | 231 mishandled_messages_ += 1; |
| 235 } | 232 } |
| 236 | 233 |
| 237 virtual void EchoResponse(const js_to_cpp::EchoArgsList& list) OVERRIDE { | 234 virtual void EchoResponse(js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 238 mishandled_messages_ += 1; | 235 mishandled_messages_ += 1; |
| 239 } | 236 } |
| 240 | 237 |
| 241 virtual void BitFlipResponse(const js_to_cpp::EchoArgsList& list) OVERRIDE { | 238 virtual void BitFlipResponse(js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 242 mishandled_messages_ += 1; | 239 mishandled_messages_ += 1; |
| 243 } | 240 } |
| 244 | 241 |
| 245 virtual void BackPointerResponse( | 242 virtual void BackPointerResponse( |
| 246 const js_to_cpp::EchoArgsList& list) OVERRIDE { | 243 js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 247 mishandled_messages_ += 1; | 244 mishandled_messages_ += 1; |
| 248 } | 245 } |
| 249 | 246 |
| 250 protected: | 247 protected: |
| 251 base::RunLoop* run_loop_; | 248 base::RunLoop* run_loop_; |
| 252 js_to_cpp::JsSide* js_side_; | 249 js_to_cpp::JsSide* js_side_; |
| 253 int mishandled_messages_; | 250 int mishandled_messages_; |
| 254 | 251 |
| 255 private: | 252 private: |
| 256 DISALLOW_COPY_AND_ASSIGN(CppSideConnection); | 253 DISALLOW_COPY_AND_ASSIGN(CppSideConnection); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 285 class EchoCppSideConnection : public CppSideConnection { | 282 class EchoCppSideConnection : public CppSideConnection { |
| 286 public: | 283 public: |
| 287 EchoCppSideConnection() : | 284 EchoCppSideConnection() : |
| 288 message_count_(0), | 285 message_count_(0), |
| 289 termination_seen_(false) { | 286 termination_seen_(false) { |
| 290 } | 287 } |
| 291 virtual ~EchoCppSideConnection() {} | 288 virtual ~EchoCppSideConnection() {} |
| 292 | 289 |
| 293 // js_to_cpp::CppSide: | 290 // js_to_cpp::CppSide: |
| 294 virtual void StartTest() OVERRIDE { | 291 virtual void StartTest() OVERRIDE { |
| 295 AllocationScope scope; | |
| 296 js_side_->Echo(kExpectedMessageCount, BuildSampleEchoArgs()); | 292 js_side_->Echo(kExpectedMessageCount, BuildSampleEchoArgs()); |
| 297 } | 293 } |
| 298 | 294 |
| 299 virtual void EchoResponse(const js_to_cpp::EchoArgsList& list) OVERRIDE { | 295 virtual void EchoResponse(js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 300 const js_to_cpp::EchoArgs& special_arg = list.item(); | 296 const js_to_cpp::EchoArgsPtr& special_arg = list->item; |
| 301 message_count_ += 1; | 297 message_count_ += 1; |
| 302 EXPECT_EQ(-1, special_arg.si64()); | 298 EXPECT_EQ(-1, special_arg->si64); |
| 303 EXPECT_EQ(-1, special_arg.si32()); | 299 EXPECT_EQ(-1, special_arg->si32); |
| 304 EXPECT_EQ(-1, special_arg.si16()); | 300 EXPECT_EQ(-1, special_arg->si16); |
| 305 EXPECT_EQ(-1, special_arg.si8()); | 301 EXPECT_EQ(-1, special_arg->si8); |
| 306 EXPECT_EQ(std::string("going"), special_arg.name().To<std::string>()); | 302 EXPECT_EQ(std::string("going"), special_arg->name.To<std::string>()); |
| 307 CheckSampleEchoArgsList(list.next()); | 303 CheckSampleEchoArgsList(list->next); |
| 308 } | 304 } |
| 309 | 305 |
| 310 virtual void TestFinished() OVERRIDE { | 306 virtual void TestFinished() OVERRIDE { |
| 311 termination_seen_ = true; | 307 termination_seen_ = true; |
| 312 run_loop()->Quit(); | 308 run_loop()->Quit(); |
| 313 } | 309 } |
| 314 | 310 |
| 315 bool DidSucceed() { | 311 bool DidSucceed() { |
| 316 return termination_seen_ && | 312 return termination_seen_ && |
| 317 !mishandled_messages_ && | 313 !mishandled_messages_ && |
| 318 message_count_ == kExpectedMessageCount; | 314 message_count_ == kExpectedMessageCount; |
| 319 } | 315 } |
| 320 | 316 |
| 321 private: | 317 private: |
| 322 static const int kExpectedMessageCount = 10; | 318 static const int kExpectedMessageCount = 10; |
| 323 int message_count_; | 319 int message_count_; |
| 324 bool termination_seen_; | 320 bool termination_seen_; |
| 325 DISALLOW_COPY_AND_ASSIGN(EchoCppSideConnection); | 321 DISALLOW_COPY_AND_ASSIGN(EchoCppSideConnection); |
| 326 }; | 322 }; |
| 327 | 323 |
| 328 // Test that corrupted messages don't wreak havoc. | 324 // Test that corrupted messages don't wreak havoc. |
| 329 class BitFlipCppSideConnection : public CppSideConnection { | 325 class BitFlipCppSideConnection : public CppSideConnection { |
| 330 public: | 326 public: |
| 331 BitFlipCppSideConnection() : termination_seen_(false) {} | 327 BitFlipCppSideConnection() : termination_seen_(false) {} |
| 332 virtual ~BitFlipCppSideConnection() {} | 328 virtual ~BitFlipCppSideConnection() {} |
| 333 | 329 |
| 334 // js_to_cpp::CppSide: | 330 // js_to_cpp::CppSide: |
| 335 virtual void StartTest() OVERRIDE { | 331 virtual void StartTest() OVERRIDE { |
| 336 AllocationScope scope; | |
| 337 js_side_->BitFlip(BuildSampleEchoArgs()); | 332 js_side_->BitFlip(BuildSampleEchoArgs()); |
| 338 } | 333 } |
| 339 | 334 |
| 340 virtual void BitFlipResponse(const js_to_cpp::EchoArgsList& list) OVERRIDE { | 335 virtual void BitFlipResponse(js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 341 CheckCorruptedEchoArgsList(list); | 336 CheckCorruptedEchoArgsList(list); |
| 342 } | 337 } |
| 343 | 338 |
| 344 virtual void TestFinished() OVERRIDE { | 339 virtual void TestFinished() OVERRIDE { |
| 345 termination_seen_ = true; | 340 termination_seen_ = true; |
| 346 run_loop()->Quit(); | 341 run_loop()->Quit(); |
| 347 } | 342 } |
| 348 | 343 |
| 349 bool DidSucceed() { | 344 bool DidSucceed() { |
| 350 return termination_seen_; | 345 return termination_seen_; |
| 351 } | 346 } |
| 352 | 347 |
| 353 private: | 348 private: |
| 354 bool termination_seen_; | 349 bool termination_seen_; |
| 355 DISALLOW_COPY_AND_ASSIGN(BitFlipCppSideConnection); | 350 DISALLOW_COPY_AND_ASSIGN(BitFlipCppSideConnection); |
| 356 }; | 351 }; |
| 357 | 352 |
| 358 // Test that severely random messages don't wreak havoc. | 353 // Test that severely random messages don't wreak havoc. |
| 359 class BackPointerCppSideConnection : public CppSideConnection { | 354 class BackPointerCppSideConnection : public CppSideConnection { |
| 360 public: | 355 public: |
| 361 BackPointerCppSideConnection() : termination_seen_(false) {} | 356 BackPointerCppSideConnection() : termination_seen_(false) {} |
| 362 virtual ~BackPointerCppSideConnection() {} | 357 virtual ~BackPointerCppSideConnection() {} |
| 363 | 358 |
| 364 // js_to_cpp::CppSide: | 359 // js_to_cpp::CppSide: |
| 365 virtual void StartTest() OVERRIDE { | 360 virtual void StartTest() OVERRIDE { |
| 366 AllocationScope scope; | |
| 367 js_side_->BackPointer(BuildSampleEchoArgs()); | 361 js_side_->BackPointer(BuildSampleEchoArgs()); |
| 368 } | 362 } |
| 369 | 363 |
| 370 virtual void BackPointerResponse( | 364 virtual void BackPointerResponse( |
| 371 const js_to_cpp::EchoArgsList& list) OVERRIDE { | 365 js_to_cpp::EchoArgsListPtr list) OVERRIDE { |
| 372 CheckCorruptedEchoArgsList(list); | 366 CheckCorruptedEchoArgsList(list); |
| 373 } | 367 } |
| 374 | 368 |
| 375 virtual void TestFinished() OVERRIDE { | 369 virtual void TestFinished() OVERRIDE { |
| 376 termination_seen_ = true; | 370 termination_seen_ = true; |
| 377 run_loop()->Quit(); | 371 run_loop()->Quit(); |
| 378 } | 372 } |
| 379 | 373 |
| 380 bool DidSucceed() { | 374 bool DidSucceed() { |
| 381 return termination_seen_; | 375 return termination_seen_; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 if (IsRunningOnIsolatedBot()) | 448 if (IsRunningOnIsolatedBot()) |
| 455 return; | 449 return; |
| 456 | 450 |
| 457 BackPointerCppSideConnection cpp_side_connection; | 451 BackPointerCppSideConnection cpp_side_connection; |
| 458 RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection); | 452 RunTest("mojo/apps/js/test/js_to_cpp_unittest", &cpp_side_connection); |
| 459 EXPECT_TRUE(cpp_side_connection.DidSucceed()); | 453 EXPECT_TRUE(cpp_side_connection.DidSucceed()); |
| 460 } | 454 } |
| 461 | 455 |
| 462 } // namespace js | 456 } // namespace js |
| 463 } // namespace mojo | 457 } // namespace mojo |
| OLD | NEW |