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

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

Issue 2984603002: Special-case Timeline.{start,finish}Sync for Fuchsia (Closed)
Patch Set: Address comments Created 3 years, 5 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
« no previous file with comments | « runtime/vm/timeline_macos.cc ('k') | runtime/vm/timeline_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 <cstring> 5 #include <cstring>
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Check phase. 154 // Check phase.
155 EXPECT_SUBSTRING("\"ph\":\"X\"", js.ToCString()); 155 EXPECT_SUBSTRING("\"ph\":\"X\"", js.ToCString());
156 // Check that ts key is present. 156 // Check that ts key is present.
157 EXPECT_SUBSTRING("\"ts\":", js.ToCString()); 157 EXPECT_SUBSTRING("\"ts\":", js.ToCString());
158 // Check that dur key is present. 158 // Check that dur key is present.
159 EXPECT_SUBSTRING("\"dur\":", js.ToCString()); 159 EXPECT_SUBSTRING("\"dur\":", js.ToCString());
160 } 160 }
161 event.DurationEnd(); 161 event.DurationEnd();
162 } 162 }
163 163
164 #if defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX)
164 TEST_CASE(TimelineEventPrintSystrace) { 165 TEST_CASE(TimelineEventPrintSystrace) {
165 const intptr_t kBufferLength = 1024; 166 const intptr_t kBufferLength = 1024;
166 char buffer[kBufferLength]; 167 char buffer[kBufferLength];
167 168
168 // Create a test stream. 169 // Create a test stream.
169 TimelineStream stream; 170 TimelineStream stream;
170 stream.Init("testStream", true); 171 stream.Init("testStream", true);
171 172
172 // Create a test event. 173 // Create a test event.
173 TimelineEvent event; 174 TimelineEvent event;
174 TimelineTestHelper::SetStream(&event, &stream); 175 TimelineTestHelper::SetStream(&event, &stream);
175 176
176 // Test a Begin event. 177 // Test a Begin event.
177 event.Begin("apple", 1, 2); 178 event.Begin("apple", 1, 2);
178 event.PrintSystrace(&buffer[0], kBufferLength); 179 TimelineEventSystraceRecorder::PrintSystrace(&event, &buffer[0],
180 kBufferLength);
179 EXPECT_SUBSTRING("|apple", buffer); 181 EXPECT_SUBSTRING("|apple", buffer);
180 EXPECT_SUBSTRING("B|", buffer); 182 EXPECT_SUBSTRING("B|", buffer);
181 183
182 // Test an End event. 184 // Test an End event.
183 event.End("apple", 2, 3); 185 event.End("apple", 2, 3);
184 event.PrintSystrace(&buffer[0], kBufferLength); 186 TimelineEventSystraceRecorder::PrintSystrace(&event, &buffer[0],
187 kBufferLength);
185 EXPECT_STREQ("E", buffer); 188 EXPECT_STREQ("E", buffer);
186 189
187 // Test a Counter event. We only report the first counter value (in this case 190 // Test a Counter event. We only report the first counter value (in this case
188 // "4"). 191 // "4").
189 event.Counter("CTR", 1); 192 event.Counter("CTR", 1);
190 // We have two counters. 193 // We have two counters.
191 event.SetNumArguments(2); 194 event.SetNumArguments(2);
192 // Set the first counter value. 195 // Set the first counter value.
193 event.CopyArgument(0, "cats", "4"); 196 event.CopyArgument(0, "cats", "4");
194 // Set the second counter value. 197 // Set the second counter value.
195 event.CopyArgument(1, "dogs", "1"); 198 event.CopyArgument(1, "dogs", "1");
196 event.PrintSystrace(&buffer[0], kBufferLength); 199 TimelineEventSystraceRecorder::PrintSystrace(&event, &buffer[0],
200 kBufferLength);
197 EXPECT_SUBSTRING("C|", buffer); 201 EXPECT_SUBSTRING("C|", buffer);
198 EXPECT_SUBSTRING("|CTR|4", buffer); 202 EXPECT_SUBSTRING("|CTR|4", buffer);
199 203
200 // Test a duration event. This event kind is not supported so we should 204 // Test a duration event. This event kind is not supported so we should
201 // serialize it to an empty string. 205 // serialize it to an empty string.
202 event.Duration("DUR", 0, 1, 2, 3); 206 event.Duration("DUR", 0, 1, 2, 3);
203 event.PrintSystrace(&buffer[0], kBufferLength); 207 TimelineEventSystraceRecorder::PrintSystrace(&event, &buffer[0],
208 kBufferLength);
204 EXPECT_STREQ("", buffer); 209 EXPECT_STREQ("", buffer);
205 } 210 }
211 #endif // defined(HOST_OS_ANDROID) || defined(HOST_OS_LINUX)
206 212
207 TEST_CASE(TimelineEventArguments) { 213 TEST_CASE(TimelineEventArguments) {
208 // Create a test stream. 214 // Create a test stream.
209 TimelineStream stream; 215 TimelineStream stream;
210 stream.Init("testStream", true); 216 stream.Init("testStream", true);
211 217
212 // Create a test event. 218 // Create a test event.
213 TimelineEvent event; 219 TimelineEvent event;
214 TimelineTestHelper::SetStream(&event, &stream); 220 TimelineTestHelper::SetStream(&event, &stream);
215 221
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 EXPECT(pauses.has_error()); 885 EXPECT(pauses.has_error());
880 } 886 }
881 TimelineTestHelper::Clear(recorder); 887 TimelineTestHelper::Clear(recorder);
882 888
883 delete recorder; 889 delete recorder;
884 } 890 }
885 891
886 #endif // !PRODUCT 892 #endif // !PRODUCT
887 893
888 } // namespace dart 894 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/timeline_macos.cc ('k') | runtime/vm/timeline_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698