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

Side by Side Diff: third_party/WebKit/Source/core/dom/ExecutionContextTaskTest.cpp

Issue 2321223003: Revert of Move collectGarbage* methods to ThreadState (Closed)
Patch Set: Created 4 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
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 "core/dom/ExecutionContextTask.h" 5 #include "core/dom/ExecutionContextTask.h"
6 6
7 #include "platform/heap/Handle.h" 7 #include "platform/heap/Handle.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 class CrossThreadTaskTest : public testing::Test { 31 class CrossThreadTaskTest : public testing::Test {
32 protected: 32 protected:
33 void SetUp() override 33 void SetUp() override
34 { 34 {
35 GCObject::s_counter = 0; 35 GCObject::s_counter = 0;
36 } 36 }
37 void TearDown() override 37 void TearDown() override
38 { 38 {
39 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, B linkGC::GCWithSweep, BlinkGC::ForcedGC); 39 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWi thSweep, BlinkGC::ForcedGC);
40 ASSERT_EQ(0, GCObject::s_counter); 40 ASSERT_EQ(0, GCObject::s_counter);
41 } 41 }
42 }; 42 };
43 43
44 TEST_F(CrossThreadTaskTest, CreateForGarbageCollectedMethod) 44 TEST_F(CrossThreadTaskTest, CreateForGarbageCollectedMethod)
45 { 45 {
46 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&GCObjec t::run, wrapCrossThreadPersistent(new GCObject), wrapCrossThreadPersistent(new G CObject)); 46 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&GCObjec t::run, wrapCrossThreadPersistent(new GCObject), wrapCrossThreadPersistent(new G CObject));
47 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&GCObjec t::run, wrapCrossThreadPersistent(new GCObject), wrapCrossThreadPersistent(new G CObject)); 47 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&GCObjec t::run, wrapCrossThreadPersistent(new GCObject), wrapCrossThreadPersistent(new G CObject));
48 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC); 48 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC);
49 EXPECT_EQ(4, GCObject::s_counter); 49 EXPECT_EQ(4, GCObject::s_counter);
50 } 50 }
51 51
52 TEST_F(CrossThreadTaskTest, CreateForFunctionWithGarbageCollected) 52 TEST_F(CrossThreadTaskTest, CreateForFunctionWithGarbageCollected)
53 { 53 {
54 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&functio nWithGarbageCollected, wrapCrossThreadPersistent(new GCObject)); 54 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&functio nWithGarbageCollected, wrapCrossThreadPersistent(new GCObject));
55 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&functio nWithGarbageCollected, wrapCrossThreadPersistent(new GCObject)); 55 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&functio nWithGarbageCollected, wrapCrossThreadPersistent(new GCObject));
56 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC); 56 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC);
57 EXPECT_EQ(2, GCObject::s_counter); 57 EXPECT_EQ(2, GCObject::s_counter);
58 } 58 }
59 59
60 TEST_F(CrossThreadTaskTest, CreateForFunctionWithExecutionContext) 60 TEST_F(CrossThreadTaskTest, CreateForFunctionWithExecutionContext)
61 { 61 {
62 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&functio nWithExecutionContext, wrapCrossThreadPersistent(new GCObject)); 62 std::unique_ptr<ExecutionContextTask> task1 = createCrossThreadTask(&functio nWithExecutionContext, wrapCrossThreadPersistent(new GCObject));
63 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&functio nWithExecutionContext, wrapCrossThreadPersistent(new GCObject)); 63 std::unique_ptr<ExecutionContextTask> task2 = createCrossThreadTask(&functio nWithExecutionContext, wrapCrossThreadPersistent(new GCObject));
64 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, Blink GC::GCWithSweep, BlinkGC::ForcedGC); 64 ThreadHeap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSw eep, BlinkGC::ForcedGC);
65 EXPECT_EQ(2, GCObject::s_counter); 65 EXPECT_EQ(2, GCObject::s_counter);
66 } 66 }
67 67
68 } // namespace blink 68 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentTest.cpp ('k') | third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698