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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 1173333007: Refactor some Timeline interfaces to be simpler and support streaming (Closed) Base URL: git@github.com:dart-lang/sdk.git@timeline2
Patch Set: Created 5 years, 6 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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 9145 matching lines...) Expand 10 before | Expand all | Expand 10 after
9156 9156
9157 TEST_CASE(Timeline_Dart_TimelineDuration) { 9157 TEST_CASE(Timeline_Dart_TimelineDuration) {
9158 Isolate* isolate = Isolate::Current(); 9158 Isolate* isolate = Isolate::Current();
9159 // Grab embedder stream. 9159 // Grab embedder stream.
9160 TimelineStream* stream = isolate->GetEmbedderStream(); 9160 TimelineStream* stream = isolate->GetEmbedderStream();
9161 // Make sure it is enabled. 9161 // Make sure it is enabled.
9162 stream->set_enabled(true); 9162 stream->set_enabled(true);
9163 // Add a duration event. 9163 // Add a duration event.
9164 Dart_TimelineDuration("testDurationEvent", 0, 1); 9164 Dart_TimelineDuration("testDurationEvent", 0, 1);
9165 // Check that it is in the output. 9165 // Check that it is in the output.
9166 TimelineEventBuffer* buffer = isolate->timeline_event_buffer(); 9166 TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
9167 JSONStream js; 9167 JSONStream js;
9168 buffer->PrintJSON(&js); 9168 recorder->PrintJSON(&js);
9169 EXPECT_SUBSTRING("testDurationEvent", js.ToCString()); 9169 EXPECT_SUBSTRING("testDurationEvent", js.ToCString());
9170 } 9170 }
9171 9171
9172 9172
9173 TEST_CASE(Timeline_Dart_TimelineInstant) { 9173 TEST_CASE(Timeline_Dart_TimelineInstant) {
9174 Isolate* isolate = Isolate::Current(); 9174 Isolate* isolate = Isolate::Current();
9175 // Grab embedder stream. 9175 // Grab embedder stream.
9176 TimelineStream* stream = isolate->GetEmbedderStream(); 9176 TimelineStream* stream = isolate->GetEmbedderStream();
9177 // Make sure it is enabled. 9177 // Make sure it is enabled.
9178 stream->set_enabled(true); 9178 stream->set_enabled(true);
9179 Dart_TimelineInstant("testInstantEvent"); 9179 Dart_TimelineInstant("testInstantEvent");
9180 // Check that it is in the output. 9180 // Check that it is in the output.
9181 TimelineEventBuffer* buffer = isolate->timeline_event_buffer(); 9181 TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
9182 JSONStream js; 9182 JSONStream js;
9183 buffer->PrintJSON(&js); 9183 recorder->PrintJSON(&js);
9184 EXPECT_SUBSTRING("testInstantEvent", js.ToCString()); 9184 EXPECT_SUBSTRING("testInstantEvent", js.ToCString());
9185 } 9185 }
9186 9186
9187 9187
9188 TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) { 9188 TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) {
9189 Isolate* isolate = Isolate::Current(); 9189 Isolate* isolate = Isolate::Current();
9190 // Grab embedder stream. 9190 // Grab embedder stream.
9191 TimelineStream* stream = isolate->GetEmbedderStream(); 9191 TimelineStream* stream = isolate->GetEmbedderStream();
9192 // Make sure it is disabled. 9192 // Make sure it is disabled.
9193 stream->set_enabled(false); 9193 stream->set_enabled(false);
9194 int64_t async_id = -1; 9194 int64_t async_id = -1;
9195 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); 9195 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id);
9196 // Expect that the |async_id| is negative because the stream is disabled. 9196 // Expect that the |async_id| is negative because the stream is disabled.
9197 EXPECT(async_id < 0); 9197 EXPECT(async_id < 0);
9198 // Call Dart_TimelineAsyncEnd with a negative async_id. 9198 // Call Dart_TimelineAsyncEnd with a negative async_id.
9199 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); 9199 Dart_TimelineAsyncEnd("testAsyncEvent", async_id);
9200 // Check that testAsync is not in the output. 9200 // Check that testAsync is not in the output.
9201 TimelineEventBuffer* buffer = isolate->timeline_event_buffer(); 9201 TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
9202 JSONStream js; 9202 JSONStream js;
9203 buffer->PrintJSON(&js); 9203 recorder->PrintJSON(&js);
9204 EXPECT_NOTSUBSTRING("testAsyncEvent", js.ToCString()); 9204 EXPECT_NOTSUBSTRING("testAsyncEvent", js.ToCString());
9205 } 9205 }
9206 9206
9207 9207
9208 TEST_CASE(Timeline_Dart_TimelineAsync) { 9208 TEST_CASE(Timeline_Dart_TimelineAsync) {
9209 Isolate* isolate = Isolate::Current(); 9209 Isolate* isolate = Isolate::Current();
9210 // Grab embedder stream. 9210 // Grab embedder stream.
9211 TimelineStream* stream = isolate->GetEmbedderStream(); 9211 TimelineStream* stream = isolate->GetEmbedderStream();
9212 // Make sure it is enabled. 9212 // Make sure it is enabled.
9213 stream->set_enabled(true); 9213 stream->set_enabled(true);
9214 int64_t async_id = -1; 9214 int64_t async_id = -1;
9215 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id); 9215 Dart_TimelineAsyncBegin("testAsyncEvent", &async_id);
9216 // Expect that the |async_id| is >= 0. 9216 // Expect that the |async_id| is >= 0.
9217 EXPECT(async_id >= 0); 9217 EXPECT(async_id >= 0);
9218 9218
9219 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); 9219 Dart_TimelineAsyncEnd("testAsyncEvent", async_id);
9220 9220
9221 // Check that it is in the output. 9221 // Check that it is in the output.
9222 TimelineEventBuffer* buffer = isolate->timeline_event_buffer(); 9222 TimelineEventRecorder* recorder = isolate->timeline_event_recorder();
9223 JSONStream js; 9223 JSONStream js;
9224 buffer->PrintJSON(&js); 9224 recorder->PrintJSON(&js);
9225 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); 9225 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString());
9226 } 9226 }
9227 9227
9228 } // namespace dart 9228 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698