OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 10 matching lines...) Expand all Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
| 31 #include "base/command_line.h" |
| 32 #include "base/message_loop/message_loop.h" |
| 33 #include "base/test/test_io_thread.h" |
31 #include "platform/EventTracer.h" | 34 #include "platform/EventTracer.h" |
32 #include "platform/HTTPNames.h" | 35 #include "platform/HTTPNames.h" |
33 #include "platform/heap/Heap.h" | 36 #include "platform/heap/Heap.h" |
34 #include "platform/testing/TestingPlatformSupport.h" | 37 #include "platform/testing/TestingPlatformSupport.h" |
| 38 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 39 #include "third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h" |
35 #include "wtf/CryptographicallyRandomNumber.h" | 40 #include "wtf/CryptographicallyRandomNumber.h" |
36 #include "wtf/MainThread.h" | 41 #include "wtf/MainThread.h" |
37 #include "wtf/Partitions.h" | 42 #include "wtf/Partitions.h" |
38 #include "wtf/WTF.h" | 43 #include "wtf/WTF.h" |
39 #include <base/bind.h> | 44 #include <base/bind.h> |
40 #include <base/bind_helpers.h> | 45 #include <base/bind_helpers.h> |
41 #include <base/test/launcher/unit_test_launcher.h> | 46 #include <base/test/launcher/unit_test_launcher.h> |
42 #include <base/test/test_suite.h> | 47 #include <base/test/test_suite.h> |
43 #include <cc/blink/web_compositor_support_impl.h> | 48 #include <cc/blink/web_compositor_support_impl.h> |
44 #include <string.h> | 49 #include <string.h> |
45 | 50 |
46 static double CurrentTime() | 51 namespace { |
| 52 |
| 53 double CurrentTime() |
47 { | 54 { |
48 return 0.0; | 55 return 0.0; |
49 } | 56 } |
50 | 57 |
51 static int runTestSuite(base::TestSuite* testSuite) | 58 void InitializeMojo() |
52 { | 59 { |
| 60 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-new-edk"); |
| 61 mojo::embedder::PreInitializeParentProcess(); |
| 62 mojo::embedder::Init(); |
| 63 } |
| 64 |
| 65 int runTestSuite(base::TestSuite* testSuite) |
| 66 { |
| 67 base::MessageLoop messageLoop; |
53 int result = testSuite->Run(); | 68 int result = testSuite->Run(); |
54 blink::Heap::collectAllGarbage(); | 69 blink::Heap::collectAllGarbage(); |
55 return result; | 70 return result; |
56 } | 71 } |
57 | 72 |
| 73 } // namespace |
| 74 |
58 int main(int argc, char** argv) | 75 int main(int argc, char** argv) |
59 { | 76 { |
60 WTF::Partitions::initialize(nullptr); | 77 WTF::Partitions::initialize(nullptr); |
61 WTF::setAlwaysZeroRandomSourceForTesting(); | 78 WTF::setAlwaysZeroRandomSourceForTesting(); |
62 WTF::initialize(CurrentTime, CurrentTime, nullptr); | 79 WTF::initialize(CurrentTime, CurrentTime, nullptr); |
63 WTF::initializeMainThread(0); | 80 WTF::initializeMainThread(0); |
64 | 81 |
65 blink::TestingPlatformSupport::Config platformConfig; | 82 blink::TestingPlatformSupport::Config platformConfig; |
66 cc_blink::WebCompositorSupportImpl compositorSupport; | 83 cc_blink::WebCompositorSupportImpl compositorSupport; |
67 platformConfig.compositorSupport = &compositorSupport; | 84 platformConfig.compositorSupport = &compositorSupport; |
68 blink::TestingPlatformSupport platform(platformConfig); | 85 blink::TestingPlatformSupport platform(platformConfig); |
69 | 86 |
70 blink::Heap::init(); | 87 blink::Heap::init(); |
71 blink::ThreadState::attachMainThread(); | 88 blink::ThreadState::attachMainThread(); |
72 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); | 89 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); |
73 blink::EventTracer::initialize(); | 90 blink::EventTracer::initialize(); |
74 | 91 |
75 blink::HTTPNames::init(); | 92 blink::HTTPNames::init(); |
76 | 93 |
77 base::TestSuite testSuite(argc, argv); | 94 base::TestSuite testSuite(argc, argv); |
| 95 |
| 96 InitializeMojo(); |
| 97 base::TestIOThread testIoThread(base::TestIOThread::kAutoStart); |
| 98 WTF::OwnPtr<mojo::test::ScopedIPCSupport> ipcSupport( |
| 99 adoptPtr(new mojo::test::ScopedIPCSupport(testIoThread.task_runner()))); |
| 100 |
78 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base
::Unretained(&testSuite))); | 101 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base
::Unretained(&testSuite))); |
79 | 102 |
80 blink::ThreadState::detachMainThread(); | 103 blink::ThreadState::detachMainThread(); |
81 blink::Heap::shutdown(); | 104 blink::Heap::shutdown(); |
82 | 105 |
83 WTF::shutdown(); | 106 WTF::shutdown(); |
84 WTF::Partitions::shutdown(); | 107 WTF::Partitions::shutdown(); |
85 return result; | 108 return result; |
86 } | 109 } |
OLD | NEW |