OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project 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 "src/heap/embedder-tracing.h" | 5 #include "src/heap/embedder-tracing.h" |
6 #include "testing/gmock/include/gmock/gmock.h" | 6 #include "testing/gmock/include/gmock/gmock.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 EXPECT_EQ(1u, local_tracer.NumberOfWrappersToTrace()); | 128 EXPECT_EQ(1u, local_tracer.NumberOfWrappersToTrace()); |
129 } | 129 } |
130 | 130 |
131 TEST(LocalEmbedderHeapTracer, TraceFinishes) { | 131 TEST(LocalEmbedderHeapTracer, TraceFinishes) { |
132 LocalEmbedderHeapTracer local_tracer; | 132 LocalEmbedderHeapTracer local_tracer; |
133 StrictMock<MockEmbedderHeapTracer> remote_tracer; | 133 StrictMock<MockEmbedderHeapTracer> remote_tracer; |
134 local_tracer.SetRemoteTracer(&remote_tracer); | 134 local_tracer.SetRemoteTracer(&remote_tracer); |
135 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); | 135 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); |
136 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); | 136 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); |
137 EXPECT_CALL(remote_tracer, RegisterV8References(_)); | 137 EXPECT_CALL(remote_tracer, RegisterV8References(_)); |
138 local_tracer.RegisterWrappersWithRemoteTracer(); | |
139 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); | 138 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); |
140 EXPECT_FALSE(local_tracer.Trace( | 139 EXPECT_FALSE(local_tracer.Trace( |
141 0, EmbedderHeapTracer::AdvanceTracingActions( | 140 0, EmbedderHeapTracer::AdvanceTracingActions( |
142 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | 141 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
143 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 142 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
144 } | 143 } |
145 | 144 |
146 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { | 145 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { |
147 LocalEmbedderHeapTracer local_tracer; | 146 LocalEmbedderHeapTracer local_tracer; |
148 StrictMock<MockEmbedderHeapTracer> remote_tracer; | 147 StrictMock<MockEmbedderHeapTracer> remote_tracer; |
149 local_tracer.SetRemoteTracer(&remote_tracer); | 148 local_tracer.SetRemoteTracer(&remote_tracer); |
150 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); | 149 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); |
151 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); | 150 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); |
152 EXPECT_CALL(remote_tracer, RegisterV8References(_)); | 151 EXPECT_CALL(remote_tracer, RegisterV8References(_)); |
153 local_tracer.RegisterWrappersWithRemoteTracer(); | |
154 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); | 152 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); |
155 EXPECT_TRUE(local_tracer.Trace( | 153 EXPECT_TRUE(local_tracer.Trace( |
156 0, EmbedderHeapTracer::AdvanceTracingActions( | 154 0, EmbedderHeapTracer::AdvanceTracingActions( |
157 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | 155 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
158 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 156 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
159 } | 157 } |
160 | 158 |
161 } // namespace heap | 159 } // namespace heap |
162 } // namespace internal | 160 } // namespace internal |
163 } // namespace v8 | 161 } // namespace v8 |
OLD | NEW |