| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 // Read in the source. | 55 // Read in the source. |
| 56 std::string source; | 56 std::string source; |
| 57 EXPECT_TRUE(ReadFileToString(path, &source)) << "Failed to read test file"; | 57 EXPECT_TRUE(ReadFileToString(path, &source)) << "Failed to read test file"; |
| 58 | 58 |
| 59 // Setup the package root. | 59 // Setup the package root. |
| 60 base::FilePath package_root; | 60 base::FilePath package_root; |
| 61 PathService::Get(base::DIR_EXE, &package_root); | 61 PathService::Get(base::DIR_EXE, &package_root); |
| 62 package_root = package_root.AppendASCII("gen"); | 62 package_root = package_root.AppendASCII("gen"); |
| 63 | 63 |
| 64 // All tests run with these arguments. | |
| 65 const int kNumArgs = 3; | |
| 66 const char* args[kNumArgs]; | |
| 67 args[0] = "--enable_asserts"; | |
| 68 args[1] = "--enable_type_checks"; | |
| 69 args[2] = "--error_on_bad_type"; | |
| 70 | |
| 71 char* error = NULL; | 64 char* error = NULL; |
| 72 bool unhandled_exception = false; | 65 bool unhandled_exception = false; |
| 73 DartControllerConfig config; | 66 DartControllerConfig config; |
| 74 config.script = source; | 67 config.script = source; |
| 68 #if defined(DEBUG) |
| 69 config.strict_compilation = true; |
| 70 #else |
| 71 config.strict_compilation = false; |
| 72 #endif |
| 75 config.script_uri = test; | 73 config.script_uri = test; |
| 76 config.package_root = package_root.AsUTF8Unsafe(); | 74 config.package_root = package_root.AsUTF8Unsafe(); |
| 77 config.application_data = nullptr; | 75 config.application_data = nullptr; |
| 78 config.callbacks.exception = | 76 config.callbacks.exception = |
| 79 base::Bind(&exceptionCallback, &unhandled_exception); | 77 base::Bind(&exceptionCallback, &unhandled_exception); |
| 80 config.entropy = generateEntropy; | 78 config.entropy = generateEntropy; |
| 81 config.arguments = args; | 79 config.arguments = nullptr; |
| 82 config.arguments_count = kNumArgs; | 80 config.arguments_count = 0; |
| 83 config.handle = MOJO_HANDLE_INVALID; | 81 config.handle = MOJO_HANDLE_INVALID; |
| 84 config.compile_all = false; | 82 config.compile_all = false; |
| 85 config.error = &error; | 83 config.error = &error; |
| 86 | 84 |
| 87 bool success = DartController::RunSingleDartScript(config); | 85 bool success = DartController::RunSingleDartScript(config); |
| 88 EXPECT_TRUE(success) << error; | 86 EXPECT_TRUE(success) << error; |
| 89 EXPECT_FALSE(unhandled_exception); | 87 EXPECT_FALSE(unhandled_exception); |
| 90 } | 88 } |
| 91 | 89 |
| 92 TEST(DartTest, validation) { | 90 TEST(DartTest, validation) { |
| 93 RunTest(GetPath()); | 91 RunTest(GetPath()); |
| 94 } | 92 } |
| 95 | 93 |
| 96 } // namespace | 94 } // namespace |
| 97 } // namespace dart | 95 } // namespace dart |
| 98 } // namespace mojo | 96 } // namespace mojo |
| OLD | NEW |