Chromium Code Reviews| 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/test/test_io_thread.h" | |
| 31 #include "platform/EventTracer.h" | 33 #include "platform/EventTracer.h" |
| 32 #include "platform/HTTPNames.h" | 34 #include "platform/HTTPNames.h" |
| 33 #include "platform/heap/Heap.h" | 35 #include "platform/heap/Heap.h" |
| 34 #include "platform/testing/TestingPlatformSupport.h" | 36 #include "platform/testing/TestingPlatformSupport.h" |
| 37 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
| 38 #include "third_party/mojo/src/mojo/edk/test/scoped_ipc_support.h" | |
| 35 #include "wtf/CryptographicallyRandomNumber.h" | 39 #include "wtf/CryptographicallyRandomNumber.h" |
| 36 #include "wtf/MainThread.h" | 40 #include "wtf/MainThread.h" |
| 37 #include "wtf/Partitions.h" | 41 #include "wtf/Partitions.h" |
| 38 #include "wtf/WTF.h" | 42 #include "wtf/WTF.h" |
| 39 #include <base/bind.h> | 43 #include <base/bind.h> |
| 40 #include <base/bind_helpers.h> | 44 #include <base/bind_helpers.h> |
| 41 #include <base/test/launcher/unit_test_launcher.h> | 45 #include <base/test/launcher/unit_test_launcher.h> |
| 42 #include <base/test/test_suite.h> | 46 #include <base/test/test_suite.h> |
| 43 #include <cc/blink/web_compositor_support_impl.h> | 47 #include <cc/blink/web_compositor_support_impl.h> |
| 44 #include <string.h> | 48 #include <string.h> |
| 45 | 49 |
| 46 static double CurrentTime() | 50 namespace { |
| 51 | |
| 52 double CurrentTime() | |
| 47 { | 53 { |
| 48 return 0.0; | 54 return 0.0; |
| 49 } | 55 } |
| 50 | 56 |
| 51 static int runTestSuite(base::TestSuite* testSuite) | 57 void InitializeMojo() |
| 58 { | |
| 59 base::CommandLine::ForCurrentProcess()->AppendSwitch("use-new-edk"); | |
| 60 mojo::embedder::PreInitializeParentProcess(); | |
| 61 mojo::embedder::Init(); | |
| 62 } | |
| 63 | |
| 64 int runTestSuite(base::TestSuite* testSuite) | |
| 52 { | 65 { |
| 53 int result = testSuite->Run(); | 66 int result = testSuite->Run(); |
| 54 blink::Heap::collectAllGarbage(); | 67 blink::Heap::collectAllGarbage(); |
| 55 return result; | 68 return result; |
| 56 } | 69 } |
| 57 | 70 |
| 71 } // namespace | |
| 72 | |
| 58 int main(int argc, char** argv) | 73 int main(int argc, char** argv) |
| 59 { | 74 { |
| 60 WTF::Partitions::initialize(nullptr); | 75 WTF::Partitions::initialize(nullptr); |
| 61 WTF::setAlwaysZeroRandomSourceForTesting(); | 76 WTF::setAlwaysZeroRandomSourceForTesting(); |
| 62 WTF::initialize(CurrentTime, CurrentTime, nullptr); | 77 WTF::initialize(CurrentTime, CurrentTime, nullptr); |
| 63 WTF::initializeMainThread(0); | 78 WTF::initializeMainThread(0); |
| 64 | 79 |
| 65 blink::TestingPlatformSupport::Config platformConfig; | 80 blink::TestingPlatformSupport::Config platformConfig; |
| 66 cc_blink::WebCompositorSupportImpl compositorSupport; | 81 cc_blink::WebCompositorSupportImpl compositorSupport; |
| 67 platformConfig.compositorSupport = &compositorSupport; | 82 platformConfig.compositorSupport = &compositorSupport; |
| 68 blink::TestingPlatformSupport platform(platformConfig); | 83 blink::TestingPlatformSupport platform(platformConfig); |
| 69 | 84 |
| 70 blink::Heap::init(); | 85 blink::Heap::init(); |
| 71 blink::ThreadState::attachMainThread(); | 86 blink::ThreadState::attachMainThread(); |
| 72 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); | 87 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); |
| 73 blink::EventTracer::initialize(); | 88 blink::EventTracer::initialize(); |
| 74 | 89 |
| 75 blink::HTTPNames::init(); | 90 blink::HTTPNames::init(); |
| 76 | 91 |
| 77 base::TestSuite testSuite(argc, argv); | 92 base::TestSuite testSuite(argc, argv); |
| 93 | |
| 94 InitializeMojo(); | |
| 95 base::TestIOThread testIoThread(base::TestIOThread::kAutoStart); | |
| 96 WTF::OwnPtr<mojo::test::ScopedIPCSupport> ipcSupport( | |
| 97 adoptPtr(new mojo::test::ScopedIPCSupport(testIoThread.task_runner()))); | |
|
haraken
2016/02/09 12:01:21
Shall we rename InitializeMojo to InitializePlatfo
Yuki
2016/02/12 12:36:14
No. We'd like to keep a ScopedIPCSupport alive wh
| |
| 98 | |
| 78 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite))); | 99 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite))); |
| 79 | 100 |
| 80 blink::ThreadState::detachMainThread(); | 101 blink::ThreadState::detachMainThread(); |
| 81 blink::Heap::shutdown(); | 102 blink::Heap::shutdown(); |
| 82 | 103 |
| 83 WTF::shutdown(); | 104 WTF::shutdown(); |
| 84 WTF::Partitions::shutdown(); | 105 WTF::Partitions::shutdown(); |
| 85 return result; | 106 return result; |
| 86 } | 107 } |
| OLD | NEW |