| 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/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 } // namespace | 244 } // namespace |
| 245 | 245 |
| 246 class DartToCppTest : public testing::Test { | 246 class DartToCppTest : public testing::Test { |
| 247 public: | 247 public: |
| 248 DartToCppTest() {} | 248 DartToCppTest() {} |
| 249 | 249 |
| 250 bool RunTest(const std::string& test, CppSideConnection* cpp_side) { | 250 bool RunTest(const std::string& test, CppSideConnection* cpp_side) { |
| 251 // Putting Dart on its own thread so we can use Dart_RunLoop (called from | 251 // Putting Dart on its own thread so we can use Dart_RunLoop (called from |
| 252 // DartController::runDartScript) and base::RunLoop::Run together. Passing | 252 // DartController::RunDartScript) and base::RunLoop::Run together. Passing |
| 253 // the thread to RunWithDartOnThread instead of inlining that function here | 253 // the thread to RunWithDartOnThread instead of inlining that function here |
| 254 // so that we are sure the MessagePipe destructor runs and closes the | 254 // so that we are sure the MessagePipe destructor runs and closes the |
| 255 // handles on the C++ side before the Thread destructor runs and joins on | 255 // handles on the C++ side before the Thread destructor runs and joins on |
| 256 // the Dart thread. Closing the handles on the C++ side must happen first | 256 // the Dart thread. Closing the handles on the C++ side must happen first |
| 257 // because it is the client, and therefore the Dart side will run and not | 257 // because it is the client, and therefore the Dart side will run and not |
| 258 // join while handles are still open, until the C++ side closes them. | 258 // join while handles are still open, until the C++ side closes them. |
| 259 base::Thread dart_thread("dart"); | 259 base::Thread dart_thread("dart"); |
| 260 cpp_side->set_run_loop(&run_loop_); | 260 cpp_side->set_run_loop(&run_loop_); |
| 261 return RunWithDartOnThread(&dart_thread, test, cpp_side); | 261 return RunWithDartOnThread(&dart_thread, test, cpp_side); |
| 262 } | 262 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 TEST_F(DartToCppTest, Echo) { | 368 TEST_F(DartToCppTest, Echo) { |
| 369 EchoCppSideConnection cpp_side_connection; | 369 EchoCppSideConnection cpp_side_connection; |
| 370 bool unhandled_exception = | 370 bool unhandled_exception = |
| 371 RunTest("dart_to_cpp_tests.dart", &cpp_side_connection); | 371 RunTest("dart_to_cpp_tests.dart", &cpp_side_connection); |
| 372 EXPECT_TRUE(cpp_side_connection.DidSucceed()); | 372 EXPECT_TRUE(cpp_side_connection.DidSucceed()); |
| 373 EXPECT_FALSE(unhandled_exception); | 373 EXPECT_FALSE(unhandled_exception); |
| 374 } | 374 } |
| 375 | 375 |
| 376 } // namespace dart | 376 } // namespace dart |
| 377 } // namespace mojo | 377 } // namespace mojo |
| OLD | NEW |