| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/json_stream.h" | 10 #include "vm/json_stream.h" |
| 11 #include "vm/metrics.h" | 11 #include "vm/metrics.h" |
| 12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 #ifndef PRODUCT |
| 17 |
| 16 UNIT_TEST_CASE(Metric_Simple) { | 18 UNIT_TEST_CASE(Metric_Simple) { |
| 17 Dart_CreateIsolate( | 19 Dart_CreateIsolate( |
| 18 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL); | 20 NULL, NULL, bin::isolate_snapshot_buffer, NULL, NULL, NULL); |
| 19 { | 21 { |
| 20 Metric metric; | 22 Metric metric; |
| 21 | 23 |
| 22 // Initialize metric. | 24 // Initialize metric. |
| 23 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kCounter); | 25 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kCounter); |
| 24 EXPECT_EQ(0, metric.value()); | 26 EXPECT_EQ(0, metric.value()); |
| 25 metric.increment(); | 27 metric.increment(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 metric.PrintJSON(&js); | 64 metric.PrintJSON(&js); |
| 63 const char* json = js.ToCString(); | 65 const char* json = js.ToCString(); |
| 64 EXPECT_STREQ("{\"type\":\"Counter\",\"name\":\"a.b.c\",\"description\":" | 66 EXPECT_STREQ("{\"type\":\"Counter\",\"name\":\"a.b.c\",\"description\":" |
| 65 "\"foobar\",\"unit\":\"byte\"," | 67 "\"foobar\",\"unit\":\"byte\"," |
| 66 "\"fixedId\":true,\"id\":\"metrics\\/native\\/a.b.c\"" | 68 "\"fixedId\":true,\"id\":\"metrics\\/native\\/a.b.c\"" |
| 67 ",\"value\":99.000000}", json); | 69 ",\"value\":99.000000}", json); |
| 68 } | 70 } |
| 69 Dart_ShutdownIsolate(); | 71 Dart_ShutdownIsolate(); |
| 70 } | 72 } |
| 71 | 73 |
| 74 #endif // !PRODUCT |
| 75 |
| 72 } // namespace dart | 76 } // namespace dart |
| OLD | NEW |