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

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

Issue 1170503004: Initial Timeline Events (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
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 9038 matching lines...) Expand 10 before | Expand all | Expand 10 after
9049 Dart_Handle result = Dart_Invoke(lib, 9049 Dart_Handle result = Dart_Invoke(lib,
9050 NewString("main"), 9050 NewString("main"),
9051 1, 9051 1,
9052 dart_args); 9052 dart_args);
9053 int64_t value = 0; 9053 int64_t value = 0;
9054 result = Dart_IntegerToInt64(result, &value); 9054 result = Dart_IntegerToInt64(result, &value);
9055 EXPECT_VALID(result); 9055 EXPECT_VALID(result);
9056 EXPECT_EQ(6, value); 9056 EXPECT_EQ(6, value);
9057 } 9057 }
9058 9058
9059
9059 TEST_CASE(StringFromExternalTypedData) { 9060 TEST_CASE(StringFromExternalTypedData) {
9060 const char* kScriptChars = 9061 const char* kScriptChars =
9061 "test(external) {\n" 9062 "test(external) {\n"
9062 " var str1 = new String.fromCharCodes(external);\n" 9063 " var str1 = new String.fromCharCodes(external);\n"
9063 " var str2 = new String.fromCharCodes(new List.from(external));\n" 9064 " var str2 = new String.fromCharCodes(new List.from(external));\n"
9064 " if (str2 != str1) throw 'FAIL';\n" 9065 " if (str2 != str1) throw 'FAIL';\n"
9065 " return str1;\n" 9066 " return str1;\n"
9066 "}\n" 9067 "}\n"
9067 "testView8(external) {\n" 9068 "testView8(external) {\n"
9068 " return test(external.buffer.asUint8List());\n" 9069 " return test(external.buffer.asUint8List());\n"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
9145 9146
9146 result = Dart_Invoke(lib, 9147 result = Dart_Invoke(lib,
9147 NewString("testView16"), 9148 NewString("testView16"),
9148 1, 9149 1,
9149 dart_args); 9150 dart_args);
9150 EXPECT_VALID(result); 9151 EXPECT_VALID(result);
9151 EXPECT(Dart_IsString(result)); 9152 EXPECT(Dart_IsString(result));
9152 } 9153 }
9153 } 9154 }
9154 9155
9156
9157 TEST_CASE(Timeline_Dart_TimelineDuration) {
9158 Isolate* isolate = Isolate::Current();
9159 // Grab embedder stream.
9160 TimelineStream* stream = isolate->GetEmbedderStream();
9161 // Make sure it is enabled.
9162 stream->set_enabled(true);
9163 // Add a duration event.
9164 Dart_TimelineDuration("testDurationEvent", 0, 1);
9165 // Check that it is in the output.
9166 TimelineEventBuffer* buffer = isolate->timeline_event_buffer();
9167 JSONStream js;
9168 buffer->PrintJSON(&js);
9169 EXPECT_SUBSTRING("testDurationEvent", js.ToCString());
9170 }
9171
9172
9173 TEST_CASE(Timeline_Dart_TimelineInstant) {
9174 Isolate* isolate = Isolate::Current();
9175 // Grab embedder stream.
9176 TimelineStream* stream = isolate->GetEmbedderStream();
9177 // Make sure it is enabled.
9178 stream->set_enabled(true);
9179 Dart_TimelineInstant("testInstantEvent");
9180 // Check that it is in the output.
9181 TimelineEventBuffer* buffer = isolate->timeline_event_buffer();
9182 JSONStream js;
9183 buffer->PrintJSON(&js);
9184 EXPECT_SUBSTRING("testInstantEvent", js.ToCString());
9185 }
9186
9187
9188 TEST_CASE(Timeline_Dart_TimelineAsyncDisabled) {
9189 Isolate* isolate = Isolate::Current();
9190 // Grab embedder stream.
9191 TimelineStream* stream = isolate->GetEmbedderStream();
9192 // Make sure it is disabled.
9193 stream->set_enabled(false);
9194 int64_t async_id = Dart_TimelineAsyncBegin("testAsyncEvent");
9195 // Expect that the |async_id| is negative because the stream is disabled.
9196 EXPECT(async_id < 0);
9197 // Call Dart_TimelineAsyncEnd with a negative async_id.
9198 Dart_TimelineAsyncEnd("testAsyncEvent", async_id);
9199 // Check that testAsync is not in the output.
9200 TimelineEventBuffer* buffer = isolate->timeline_event_buffer();
9201 JSONStream js;
9202 buffer->PrintJSON(&js);
9203 EXPECT_NOTSUBSTRING("testAsyncEvent", js.ToCString());
9204 }
9205
9206
9207 TEST_CASE(Timeline_Dart_TimelineAsync) {
9208 Isolate* isolate = Isolate::Current();
9209 // Grab embedder stream.
9210 TimelineStream* stream = isolate->GetEmbedderStream();
9211 // Make sure it is enabled.
9212 stream->set_enabled(true);
9213 int64_t async_id = Dart_TimelineAsyncBegin("testAsyncEvent");
9214 // Expect that the |async_id| is >= 0.
9215 EXPECT(async_id >= 0);
9216
9217 Dart_TimelineAsyncEnd("testAsyncEvent", async_id);
9218
9219 // Check that it is in the output.
9220 TimelineEventBuffer* buffer = isolate->timeline_event_buffer();
9221 JSONStream js;
9222 buffer->PrintJSON(&js);
9223 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString());
9224 }
9225
9155 } // namespace dart 9226 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698