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

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

Issue 2666133002: Added new type of unit test, RAW_UNIT_TEST_CASE, which is used for tests that can be flaky if run w… (Closed)
Patch Set: Fixed name of UNIT_TEST_CASE macro Created 3 years, 10 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/message_handler_test.cc ('k') | runtime/vm/object_graph_test.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) 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 16 #ifndef PRODUCT
17 17
18 UNIT_TEST_CASE(Metric_Simple) { 18 VM_UNIT_TEST_CASE(Metric_Simple) {
19 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, 19 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data,
20 bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); 20 bin::core_isolate_snapshot_instructions, NULL, NULL, NULL);
21 { 21 {
22 Metric metric; 22 Metric metric;
23 23
24 // Initialize metric. 24 // Initialize metric.
25 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kCounter); 25 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kCounter);
26 EXPECT_EQ(0, metric.value()); 26 EXPECT_EQ(0, metric.value());
27 metric.increment(); 27 metric.increment();
28 EXPECT_EQ(1, metric.value()); 28 EXPECT_EQ(1, metric.value());
29 metric.set_value(44); 29 metric.set_value(44);
30 EXPECT_EQ(44, metric.value()); 30 EXPECT_EQ(44, metric.value());
31 } 31 }
32 Dart_ShutdownIsolate(); 32 Dart_ShutdownIsolate();
33 } 33 }
34 34
35 class MyMetric : public Metric { 35 class MyMetric : public Metric {
36 protected: 36 protected:
37 int64_t Value() const { 37 int64_t Value() const {
38 // 99 bytes. 38 // 99 bytes.
39 return 99; 39 return 99;
40 } 40 }
41 41
42 public: 42 public:
43 // Just used for testing. 43 // Just used for testing.
44 int64_t LeakyValue() const { return Value(); } 44 int64_t LeakyValue() const { return Value(); }
45 }; 45 };
46 46
47 UNIT_TEST_CASE(Metric_OnDemand) { 47 VM_UNIT_TEST_CASE(Metric_OnDemand) {
48 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data, 48 Dart_CreateIsolate(NULL, NULL, bin::core_isolate_snapshot_data,
49 bin::core_isolate_snapshot_instructions, NULL, NULL, NULL); 49 bin::core_isolate_snapshot_instructions, NULL, NULL, NULL);
50 { 50 {
51 Thread* thread = Thread::Current(); 51 Thread* thread = Thread::Current();
52 StackZone zone(thread); 52 StackZone zone(thread);
53 HANDLESCOPE(thread); 53 HANDLESCOPE(thread);
54 MyMetric metric; 54 MyMetric metric;
55 55
56 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kByte); 56 metric.Init(Isolate::Current(), "a.b.c", "foobar", Metric::kByte);
57 // value is still the default value. 57 // value is still the default value.
(...skipping 11 matching lines...) Expand all
69 "\"fixedId\":true,\"id\":\"metrics\\/native\\/a.b.c\"" 69 "\"fixedId\":true,\"id\":\"metrics\\/native\\/a.b.c\""
70 ",\"value\":99.000000}", 70 ",\"value\":99.000000}",
71 json); 71 json);
72 } 72 }
73 Dart_ShutdownIsolate(); 73 Dart_ShutdownIsolate();
74 } 74 }
75 75
76 #endif // !PRODUCT 76 #endif // !PRODUCT
77 77
78 } // namespace dart 78 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/message_handler_test.cc ('k') | runtime/vm/object_graph_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698