OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/globals.h" | 6 #include "vm/globals.h" |
7 #include "vm/json_stream.h" | 7 #include "vm/json_stream.h" |
8 #include "vm/trace_buffer.h" | 8 #include "vm/trace_buffer.h" |
9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 trace_buffer->TraceF("foo %d %s", 99, "bar"); | 97 trace_buffer->TraceF("foo %d %s", 99, "bar"); |
98 { | 98 { |
99 JSONStream js; | 99 JSONStream js; |
100 trace_buffer->PrintToJSONStream(&js); | 100 trace_buffer->PrintToJSONStream(&js); |
101 EXPECT_SUBSTRING("foo 99 bar", js.ToCString()); | 101 EXPECT_SUBSTRING("foo 99 bar", js.ToCString()); |
102 } | 102 } |
103 delete trace_buffer; | 103 delete trace_buffer; |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 TEST_CASE(TraceBufferTraceWarning) { | |
108 Isolate* isolate = Isolate::Current(); | |
109 TraceBuffer::Init(isolate, 3); | |
110 TraceBuffer* trace_buffer = isolate->trace_buffer(); | |
111 const String& url = String::Handle(isolate, String::New("Plug")); | |
112 const String& source = String::Handle(isolate, String::New("240V")); | |
113 const Script& script = Script::Handle(isolate, | |
114 Script::New(url, source, RawScript::kScriptTag)); | |
115 const intptr_t token_pos = 0; | |
116 const char* message = "High Voltage"; | |
117 TraceBuffer::TraceWarningF(isolate, script, token_pos, "%s", message); | |
118 { | |
119 JSONStream js; | |
120 trace_buffer->PrintToJSONStream(&js); | |
Cutch
2014/06/11 21:45:03
For testing, we could add accessors:
At(intptr_t
regis
2014/06/11 23:48:35
Done.
| |
121 EXPECT_SUBSTRING("{\"type\":\"TraceBuffer\",\"members\":[" | |
122 "{\"type\":\"TraceBufferEntry\",\"time\":", | |
123 js.ToCString()); | |
124 // Skip time. | |
125 EXPECT_SUBSTRING("\"message\":\"{\\\"type\\\":\\\"TraceBufferWarning\\\"," | |
126 "\\\"script_url\\\":\\\"Plug\\\",\\\"token_pos\\\":0," | |
Cutch
2014/06/11 21:45:03
Please also add a test that exercises PrintToJSONS
regis
2014/06/11 23:48:35
Done.
| |
127 "\\\"message\\\":\\\"High Voltage\\\"\"}]}", | |
128 js.ToCString()); | |
129 } | |
130 delete trace_buffer; | |
131 } | |
132 | |
107 } // namespace dart | 133 } // namespace dart |
OLD | NEW |