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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); | 138 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(false)); |
139 EXPECT_EQ( | 139 EXPECT_FALSE(local_tracer.Trace( |
140 false, | 140 0, EmbedderHeapTracer::AdvanceTracingActions( |
141 local_tracer.Trace( | 141 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
142 0, EmbedderHeapTracer::AdvanceTracingActions( | |
143 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | |
144 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 142 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
145 } | 143 } |
146 | 144 |
147 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { | 145 TEST(LocalEmbedderHeapTracer, TraceDoesNotFinish) { |
148 LocalEmbedderHeapTracer local_tracer; | 146 LocalEmbedderHeapTracer local_tracer; |
149 StrictMock<MockEmbedderHeapTracer> remote_tracer; | 147 StrictMock<MockEmbedderHeapTracer> remote_tracer; |
150 local_tracer.SetRemoteTracer(&remote_tracer); | 148 local_tracer.SetRemoteTracer(&remote_tracer); |
151 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); | 149 local_tracer.AddWrapperToTrace(CreateWrapperInfo()); |
152 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); | 150 EXPECT_EQ(1u, local_tracer.NumberOfCachedWrappersToTrace()); |
153 EXPECT_CALL(remote_tracer, RegisterV8References(_)); | 151 EXPECT_CALL(remote_tracer, RegisterV8References(_)); |
154 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); | 152 EXPECT_CALL(remote_tracer, AdvanceTracing(0, _)).WillOnce(Return(true)); |
155 EXPECT_EQ( | 153 EXPECT_TRUE(local_tracer.Trace( |
156 true, | 154 0, EmbedderHeapTracer::AdvanceTracingActions( |
157 local_tracer.Trace( | 155 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); |
158 0, EmbedderHeapTracer::AdvanceTracingActions( | |
159 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION))); | |
160 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); | 156 EXPECT_EQ(0u, local_tracer.NumberOfCachedWrappersToTrace()); |
161 } | 157 } |
162 | 158 |
163 } // namespace heap | 159 } // namespace heap |
164 } // namespace internal | 160 } // namespace internal |
165 } // namespace v8 | 161 } // namespace v8 |
OLD | NEW |