Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: mojo/dart/embedder/test/dart_test.cc

Issue 1545483003: Dart: Reorganize files (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix build file Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/dart/embedder/test/dart_test.h ('k') | mojo/dart/embedder/test/dart_to_cpp.mojom » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "mojo/dart/embedder/test/dart_test.h"
6
7 #include "base/bind.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10 #include "base/rand_util.h"
11 #include "mojo/dart/embedder/dart_controller.h"
12 #include "mojo/public/c/system/types.h"
13 #include "mojo/public/cpp/environment/environment.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace mojo {
17 namespace dart {
18
19 void DartTest::RunDartTest(const base::FilePath& path,
20 const std::vector<std::string>& script_arguments,
21 bool compile_all,
22 bool expect_unhandled_exception,
23 int expected_unclosed_handles) {
24 // Grab the C string pointer.
25 std::vector<const char*> script_arguments_c_str;
26 for (size_t i = 0; i < script_arguments.size(); i++) {
27 script_arguments_c_str.push_back(script_arguments[i].c_str());
28 }
29 DCHECK(script_arguments.size() == script_arguments_c_str.size());
30
31 // Setup the package root.
32 base::FilePath package_root;
33 PathService::Get(base::DIR_EXE, &package_root);
34 package_root = package_root.AppendASCII("gen")
35 .AppendASCII("dart-pkg")
36 .AppendASCII("packages");
37
38 char* error = nullptr;
39 bool unhandled_exception = false;
40 int64_t closed_handles = 0;
41 DartControllerConfig config;
42 // Run with strict compilation even in Release mode so that ASAN testing gets
43 // coverage of Dart asserts, type-checking, etc.
44 config.strict_compilation = true;
45 config.compile_all = compile_all;
46 config.script_uri = path.AsUTF8Unsafe();
47 config.package_root = package_root.AsUTF8Unsafe();
48 config.callbacks.exception =
49 base::Bind(&ExceptionCallback, &unhandled_exception, &closed_handles);
50 config.entropy = GenerateEntropy;
51 config.error = &error;
52
53 if (script_arguments_c_str.size() > 0) {
54 config.SetScriptFlags(script_arguments_c_str.data(),
55 script_arguments_c_str.size());
56 }
57
58 bool success = DartController::RunDartScript(config);
59 EXPECT_TRUE(success) << error;
60 EXPECT_EQ(expect_unhandled_exception, unhandled_exception);
61 EXPECT_EQ(expected_unclosed_handles, closed_handles);
62 }
63
64 } // namespace dart
65 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/dart/embedder/test/dart_test.h ('k') | mojo/dart/embedder/test/dart_to_cpp.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698