| 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/test/test_io_thread.h" |
| 32 #include "mojo/edk/embedder/embedder.h" |
| 33 #include "mojo/edk/test/scoped_ipc_support.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" |
| 35 #include "wtf/CryptographicallyRandomNumber.h" | 38 #include "wtf/CryptographicallyRandomNumber.h" |
| 36 #include "wtf/CurrentTime.h" | 39 #include "wtf/CurrentTime.h" |
| 37 #include "wtf/MainThread.h" | 40 #include "wtf/MainThread.h" |
| 38 #include "wtf/Partitions.h" | 41 #include "wtf/Partitions.h" |
| 39 #include "wtf/WTF.h" | 42 #include "wtf/WTF.h" |
| 40 #include <base/bind.h> | 43 #include <base/bind.h> |
| 41 #include <base/bind_helpers.h> | 44 #include <base/bind_helpers.h> |
| 42 #include <base/command_line.h> | 45 #include <base/command_line.h> |
| 43 #include <base/test/launcher/unit_test_launcher.h> | 46 #include <base/test/launcher/unit_test_launcher.h> |
| 44 #include <base/test/test_suite.h> | 47 #include <base/test/test_suite.h> |
| 45 #include <cc/blink/web_compositor_support_impl.h> | 48 #include <cc/blink/web_compositor_support_impl.h> |
| 46 #include <string.h> | |
| 47 | 49 |
| 48 static double dummyCurrentTime() | 50 namespace { |
| 51 |
| 52 double dummyCurrentTime() |
| 49 { | 53 { |
| 50 return 0.0; | 54 return 0.0; |
| 51 } | 55 } |
| 52 | 56 |
| 53 static int runTestSuite(base::TestSuite* testSuite) | 57 int runTestSuite(base::TestSuite* testSuite) |
| 54 { | 58 { |
| 55 int result = testSuite->Run(); | 59 int result = testSuite->Run(); |
| 56 blink::Heap::collectAllGarbage(); | 60 blink::Heap::collectAllGarbage(); |
| 57 return result; | 61 return result; |
| 58 } | 62 } |
| 59 | 63 |
| 64 } // namespace |
| 65 |
| 60 int main(int argc, char** argv) | 66 int main(int argc, char** argv) |
| 61 { | 67 { |
| 62 base::CommandLine::Init(argc, argv); | 68 base::CommandLine::Init(argc, argv); |
| 63 | 69 |
| 64 WTF::Partitions::initialize(nullptr); | 70 WTF::Partitions::initialize(nullptr); |
| 65 WTF::setTimeFunctionsForTesting(dummyCurrentTime); | 71 WTF::setTimeFunctionsForTesting(dummyCurrentTime); |
| 66 WTF::initialize(nullptr); | 72 WTF::initialize(nullptr); |
| 67 WTF::initializeMainThread(0); | 73 WTF::initializeMainThread(0); |
| 68 | 74 |
| 69 blink::TestingPlatformSupport::Config platformConfig; | 75 blink::TestingPlatformSupport::Config platformConfig; |
| 70 cc_blink::WebCompositorSupportImpl compositorSupport; | 76 cc_blink::WebCompositorSupportImpl compositorSupport; |
| 71 platformConfig.compositorSupport = &compositorSupport; | 77 platformConfig.compositorSupport = &compositorSupport; |
| 72 blink::TestingPlatformSupport platform(platformConfig); | 78 blink::TestingPlatformSupport platform(platformConfig); |
| 73 | 79 |
| 74 blink::Heap::init(); | 80 blink::Heap::init(); |
| 75 blink::ThreadState::attachMainThread(); | 81 blink::ThreadState::attachMainThread(); |
| 76 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); | 82 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); |
| 77 blink::EventTracer::initialize(); | 83 blink::EventTracer::initialize(); |
| 78 | 84 |
| 79 blink::HTTPNames::init(); | 85 blink::HTTPNames::init(); |
| 80 | 86 |
| 81 base::TestSuite testSuite(argc, argv); | 87 base::TestSuite testSuite(argc, argv); |
| 88 |
| 89 mojo::edk::Init(); |
| 90 base::TestIOThread testIoThread(base::TestIOThread::kAutoStart); |
| 91 WTF::OwnPtr<mojo::edk::test::ScopedIPCSupport> ipcSupport( |
| 92 adoptPtr(new mojo::edk::test::ScopedIPCSupport(testIoThread.task_runner(
)))); |
| 93 |
| 82 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base
::Unretained(&testSuite))); | 94 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base
::Unretained(&testSuite))); |
| 83 | 95 |
| 84 blink::ThreadState::detachMainThread(); | 96 blink::ThreadState::detachMainThread(); |
| 85 blink::Heap::shutdown(); | 97 blink::Heap::shutdown(); |
| 86 | 98 |
| 87 WTF::shutdown(); | 99 WTF::shutdown(); |
| 88 WTF::Partitions::shutdown(); | 100 WTF::Partitions::shutdown(); |
| 89 return result; | 101 return result; |
| 90 } | 102 } |
| OLD | NEW |