Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 1 | // Copyright 2018 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 "base/bind.h" |
| 6 | #include "base/command_line.h" |
Carlos Caballero | a1f7a0d | 2019-06-12 08:20:34 | [diff] [blame] | 7 | #include "base/task/single_thread_task_executor.h" |
Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 8 | #include "base/test/launcher/unit_test_launcher.h" |
| 9 | #include "base/test/test_suite.h" |
| 10 | #include "testing/gmock/include/gmock/gmock.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | namespace { |
| 14 | |
| 15 | int RunHelper(base::TestSuite* test_suite) { |
Carlos Caballero | a1f7a0d | 2019-06-12 08:20:34 | [diff] [blame] | 16 | base::SingleThreadTaskExecutor task_executor; |
Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 17 | return test_suite->Run(); |
| 18 | } |
| 19 | |
| 20 | } // namespace |
| 21 | |
Corentin Wallez | 248a1fa | 2019-02-20 12:05:05 | [diff] [blame] | 22 | // Definition located in third_party/dawn/src/tests/DawnTest.h |
| 23 | // Forward declared here to avoid pulling in the Dawn headers. |
| 24 | void InitDawnEnd2EndTestEnvironment(int argc, char** argv); |
| 25 | |
Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 26 | int main(int argc, char** argv) { |
| 27 | base::CommandLine::Init(argc, argv); |
Austin Eng | 9b8406b | 2020-05-11 13:19:11 | [diff] [blame] | 28 | |
| 29 | // Environment initialization is done before test initialization |
| 30 | // so tests can be instantiated for each available GPU adapter. |
| 31 | InitDawnEnd2EndTestEnvironment(argc, argv); |
| 32 | |
Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 33 | testing::InitGoogleMock(&argc, argv); |
| 34 | base::TestSuite test_suite(argc, argv); |
Corentin Wallez | 0b71452b | 2018-10-30 17:35:00 | [diff] [blame] | 35 | int rt = base::LaunchUnitTestsWithOptions( |
| 36 | argc, argv, |
| 37 | 1, // Run tests serially. |
| 38 | 0, // Disable batching. |
| 39 | true, // Use job objects. |
| 40 | base::BindOnce(&RunHelper, base::Unretained(&test_suite))); |
| 41 | return rt; |
| 42 | } |