| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_DART_EMBEDDER_TEST_DART_TEST_H_ | |
| 6 #define MOJO_DART_EMBEDDER_TEST_DART_TEST_H_ | |
| 7 | |
| 8 #include "base/bind.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/path_service.h" | |
| 11 #include "base/rand_util.h" | |
| 12 #include "mojo/dart/embedder/dart_controller.h" | |
| 13 #include "mojo/public/c/system/types.h" | |
| 14 #include "mojo/public/cpp/environment/environment.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | |
| 16 | |
| 17 namespace mojo { | |
| 18 namespace dart { | |
| 19 | |
| 20 class DartTest : public testing::Test { | |
| 21 public: | |
| 22 DartTest() {} | |
| 23 | |
| 24 static void SetUpTestCase() { | |
| 25 DartController::Initialize(nullptr, true, false, nullptr, 0); | |
| 26 } | |
| 27 | |
| 28 static void TearDownTestCase() { | |
| 29 DartController::Shutdown(); | |
| 30 } | |
| 31 | |
| 32 void RunDartTest(const base::FilePath& path, | |
| 33 const std::vector<std::string>& script_arguments, | |
| 34 bool compile_all, | |
| 35 bool expect_unhandled_exception, | |
| 36 int expected_unclosed_handles); | |
| 37 | |
| 38 protected: | |
| 39 static bool GenerateEntropy(uint8_t* buffer, intptr_t length) { | |
| 40 base::RandBytes(static_cast<void*>(buffer), length); | |
| 41 return true; | |
| 42 } | |
| 43 | |
| 44 static void ExceptionCallback(bool* exception, | |
| 45 int64_t* closed_handles, | |
| 46 Dart_Handle error, | |
| 47 int64_t count) { | |
| 48 EXPECT_TRUE(Dart_IsError(error)); | |
| 49 *exception = true; | |
| 50 *closed_handles = count; | |
| 51 } | |
| 52 }; | |
| 53 | |
| 54 } // namespace dart | |
| 55 } // namespace mojo | |
| 56 | |
| 57 #endif // MOJO_DART_EMBEDDER_TEST_DART_TEST_H_ | |
| OLD | NEW |