OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
| 9200 |
| 9201 |
| 9202 TEST_CASE(Timeline_Dart_TimelineAsync) { |
| 9203 Isolate* isolate = Isolate::Current(); |
| 9204 // Grab embedder stream. |
| 9205 TimelineStream* stream = isolate->GetEmbedderStream(); |
| 9206 // Make sure it is enabled. |
| 9207 stream->set_enabled(true); |
| 9208 int64_t async_id = Dart_TimelineAsyncBegin("testAsyncEvent"); |
| 9209 // Expect that the |async_id| is >= 0. |
| 9210 EXPECT(async_id >= 0); |
| 9211 // Call Dart_TimelineAsyncEnd with a negative async_id. |
| 9212 Dart_TimelineAsyncEnd("testAsyncEvent", async_id); |
| 9213 |
| 9214 // Check that it is in the output. |
| 9215 TimelineEventBuffer* buffer = isolate->timeline_event_buffer(); |
| 9216 JSONStream js; |
| 9217 buffer->PrintJSON(&js); |
| 9218 EXPECT_SUBSTRING("testAsyncEvent", js.ToCString()); |
| 9219 } |
| 9220 |
9155 } // namespace dart | 9221 } // namespace dart |
OLD | NEW |