Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: Source/modules/compositorworker/CompositorWorkerManagerTest.cpp

Issue 1316233004: Force running GC on the worker thread before the unit test exits (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/workers/WorkerThreadTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "modules/compositorworker/CompositorWorkerManager.h" 6 #include "modules/compositorworker/CompositorWorkerManager.h"
7 7
8 #include "bindings/core/v8/ScriptSourceCode.h" 8 #include "bindings/core/v8/ScriptSourceCode.h"
9 #include "core/inspector/ConsoleMessage.h" 9 #include "core/inspector/ConsoleMessage.h"
10 #include "core/testing/DummyPageHolder.h" 10 #include "core/testing/DummyPageHolder.h"
11 #include "core/workers/WorkerLoaderProxy.h" 11 #include "core/workers/WorkerLoaderProxy.h"
12 #include "core/workers/WorkerObjectProxy.h" 12 #include "core/workers/WorkerObjectProxy.h"
13 #include "core/workers/WorkerThreadStartupData.h" 13 #include "core/workers/WorkerThreadStartupData.h"
14 #include "modules/compositorworker/CompositorWorkerThread.h" 14 #include "modules/compositorworker/CompositorWorkerThread.h"
15 #include "platform/NotImplemented.h" 15 #include "platform/NotImplemented.h"
16 #include "platform/ThreadSafeFunctional.h" 16 #include "platform/ThreadSafeFunctional.h"
17 #include "platform/heap/Heap.h"
17 #include "platform/testing/UnitTestHelpers.h" 18 #include "platform/testing/UnitTestHelpers.h"
18 #include "public/platform/Platform.h" 19 #include "public/platform/Platform.h"
19 #include "public/platform/WebWaitableEvent.h" 20 #include "public/platform/WebWaitableEvent.h"
20 #include <gtest/gtest.h> 21 #include <gtest/gtest.h>
22 #include <v8.h>
21 23
22 namespace blink { 24 namespace blink {
23 namespace { 25 namespace {
24 26
25 class TestCompositorWorkerThread : public CompositorWorkerThread { 27 class TestCompositorWorkerThread : public CompositorWorkerThread {
26 public: 28 public:
27 TestCompositorWorkerThread(WorkerLoaderProxyProvider* loaderProxyProvider, W orkerObjectProxy& objectProxy, double timeOrigin, WebWaitableEvent* startEvent) 29 TestCompositorWorkerThread(WorkerLoaderProxyProvider* loaderProxyProvider, W orkerObjectProxy& objectProxy, double timeOrigin, WebWaitableEvent* startEvent)
28 : CompositorWorkerThread(WorkerLoaderProxy::create(loaderProxyProvider), objectProxy, timeOrigin) 30 : CompositorWorkerThread(WorkerLoaderProxy::create(loaderProxyProvider), objectProxy, timeOrigin)
29 , m_startEvent(startEvent) 31 , m_startEvent(startEvent)
30 { 32 {
(...skipping 11 matching lines...) Expand all
42 void didStartRunLoop() override 44 void didStartRunLoop() override
43 { 45 {
44 m_startEvent->signal(); 46 m_startEvent->signal();
45 } 47 }
46 void terminateV8Execution() override 48 void terminateV8Execution() override
47 { 49 {
48 CompositorWorkerThread::terminateV8Execution(); 50 CompositorWorkerThread::terminateV8Execution();
49 if (m_v8TerminationCallback) 51 if (m_v8TerminationCallback)
50 (*m_v8TerminationCallback)(); 52 (*m_v8TerminationCallback)();
51 } 53 }
54 void willDestroyIsolate() override
55 {
56 v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting(v8::Isolat e::kFullGarbageCollection);
57 Heap::collectAllGarbage();
58 CompositorWorkerThread::willDestroyIsolate();
59 }
52 60
53 WebWaitableEvent* m_startEvent; 61 WebWaitableEvent* m_startEvent;
54 OwnPtr<Function<void()>> m_v8TerminationCallback; 62 OwnPtr<Function<void()>> m_v8TerminationCallback;
55 }; 63 };
56 64
57 // A null WorkerObjectProxy, supplied when creating CompositorWorkerThreads. 65 // A null WorkerObjectProxy, supplied when creating CompositorWorkerThreads.
58 class TestCompositorWorkerObjectProxy : public WorkerObjectProxy { 66 class TestCompositorWorkerObjectProxy : public WorkerObjectProxy {
59 public: 67 public:
60 static PassOwnPtr<TestCompositorWorkerObjectProxy> create(ExecutionContext* context) 68 static PassOwnPtr<TestCompositorWorkerObjectProxy> create(ExecutionContext* context)
61 { 69 {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 v8::Isolate* secondIsolate = secondWorker->isolate(); 265 v8::Isolate* secondIsolate = secondWorker->isolate();
258 ASSERT(secondIsolate); 266 ASSERT(secondIsolate);
259 EXPECT_EQ(firstIsolate, secondIsolate); 267 EXPECT_EQ(firstIsolate, secondIsolate);
260 268
261 // Verify that the isolate can run some scripts correctly in the second work er. 269 // Verify that the isolate can run some scripts correctly in the second work er.
262 checkWorkerCanExecuteScript(secondWorker.get()); 270 checkWorkerCanExecuteScript(secondWorker.get());
263 secondWorker->terminateAndWait(); 271 secondWorker->terminateAndWait();
264 } 272 }
265 273
266 } // namespace blink 274 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerThreadTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698