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 15 matching lines...) Expand all Loading... | |
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 "platform/EventTracer.h" | 31 #include "platform/EventTracer.h" |
32 #include "platform/HTTPNames.h" | 32 #include "platform/HTTPNames.h" |
33 #include "platform/heap/Heap.h" | 33 #include "platform/heap/Heap.h" |
34 #include "platform/testing/TestingPlatformSupport.h" | 34 #include "platform/testing/TestingPlatformSupport.h" |
35 #include "wtf/CryptographicallyRandomNumber.h" | 35 #include "wtf/CryptographicallyRandomNumber.h" |
36 #include "wtf/CurrentTime.h" | |
36 #include "wtf/MainThread.h" | 37 #include "wtf/MainThread.h" |
37 #include "wtf/Partitions.h" | 38 #include "wtf/Partitions.h" |
38 #include "wtf/WTF.h" | 39 #include "wtf/WTF.h" |
39 #include <base/bind.h> | 40 #include <base/bind.h> |
40 #include <base/bind_helpers.h> | 41 #include <base/bind_helpers.h> |
41 #include <base/test/launcher/unit_test_launcher.h> | 42 #include <base/test/launcher/unit_test_launcher.h> |
42 #include <base/test/test_suite.h> | 43 #include <base/test/test_suite.h> |
43 #include <cc/blink/web_compositor_support_impl.h> | 44 #include <cc/blink/web_compositor_support_impl.h> |
44 #include <string.h> | 45 #include <string.h> |
45 | 46 |
46 static double CurrentTime() | |
47 { | |
48 return 0.0; | |
49 } | |
50 | |
51 static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) | 47 static void AlwaysZeroNumberSource(unsigned char* buf, size_t len) |
52 { | 48 { |
53 memset(buf, '\0', len); | 49 memset(buf, '\0', len); |
54 } | 50 } |
55 | 51 |
56 static int runTestSuite(base::TestSuite* testSuite) | 52 static int runTestSuite(base::TestSuite* testSuite) |
57 { | 53 { |
58 int result = testSuite->Run(); | 54 int result = testSuite->Run(); |
59 blink::Heap::collectAllGarbage(); | 55 blink::Heap::collectAllGarbage(); |
60 return result; | 56 return result; |
61 } | 57 } |
62 | 58 |
63 int main(int argc, char** argv) | 59 int main(int argc, char** argv) |
64 { | 60 { |
65 WTF::setRandomSource(AlwaysZeroNumberSource); | 61 WTF::setRandomSource(AlwaysZeroNumberSource); |
66 WTF::initialize(CurrentTime, CurrentTime, CurrentTime, nullptr, nullptr); | 62 WTF::setTimeFunctionsForTesting([]() -> double { |
haraken
2015/12/28 02:24:27
Nit: I've never seen Blink using the []()-> syntax
Yuta Kitamura
2016/01/05 05:31:06
I think mine is clearer and simpler, but I'd defer
| |
63 return 0.0; | |
64 }); | |
65 WTF::initialize(nullptr, nullptr); | |
67 WTF::initializeMainThread(0); | 66 WTF::initializeMainThread(0); |
68 | 67 |
69 blink::TestingPlatformSupport::Config platformConfig; | 68 blink::TestingPlatformSupport::Config platformConfig; |
70 cc_blink::WebCompositorSupportImpl compositorSupport; | 69 cc_blink::WebCompositorSupportImpl compositorSupport; |
71 platformConfig.compositorSupport = &compositorSupport; | 70 platformConfig.compositorSupport = &compositorSupport; |
72 blink::TestingPlatformSupport platform(platformConfig); | 71 blink::TestingPlatformSupport platform(platformConfig); |
73 | 72 |
74 blink::Heap::init(); | 73 blink::Heap::init(); |
75 blink::ThreadState::attachMainThread(); | 74 blink::ThreadState::attachMainThread(); |
76 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); | 75 blink::ThreadState::current()->registerTraceDOMWrappers(nullptr, nullptr); |
77 blink::EventTracer::initialize(); | 76 blink::EventTracer::initialize(); |
78 | 77 |
79 blink::HTTPNames::init(); | 78 blink::HTTPNames::init(); |
80 | 79 |
81 base::TestSuite testSuite(argc, argv); | 80 base::TestSuite testSuite(argc, argv); |
82 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite))); | 81 int result = base::LaunchUnitTests(argc, argv, base::Bind(runTestSuite, base ::Unretained(&testSuite))); |
83 | 82 |
84 blink::ThreadState::detachMainThread(); | 83 blink::ThreadState::detachMainThread(); |
85 blink::Heap::shutdown(); | 84 blink::Heap::shutdown(); |
86 | 85 |
87 WTF::shutdown(); | 86 WTF::shutdown(); |
88 return result; | 87 return result; |
89 } | 88 } |
OLD | NEW |