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

Side by Side Diff: tests/lib/profiler/metrics_test.dart

Issue 409213004: Initial backend for metrics in Observatory (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/profiler/profiler.dart ('k') | tests/standalone/issue14236_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 //
5
6 import 'dart:profiler';
7 import 'package:expect/expect.dart';
8
9 testGauge1() {
10 var gauge = new Gauge('test', 'alpha bravo', 0.0, 100.0);
11 Expect.equals(0.0, gauge.min);
12 Expect.equals(0.0, gauge.value);
13 Expect.equals(100.0, gauge.max);
14 Expect.equals('test', gauge.name);
15 Expect.equals('alpha bravo', gauge.description);
16 gauge.value = 44.0;
17 Expect.equals(44.0, gauge.value);
18 // Test setting below min.
19 gauge.value = -1.0;
20 Expect.equals(0.0, gauge.value);
21 // Test setting above max.
22 gauge.value = 101.0;
23 Expect.equals(100.0, gauge.value);
24 }
25
26 testGauge2() {
27 var gauge = new Gauge('test', 'alpha bravo', 1.0, 2.0);
28 Expect.equals(1.0, gauge.min);
29 Expect.equals(2.0, gauge.max);
30 Expect.equals(gauge.min, gauge.value);
31 Expect.equals('test', gauge.name);
32 Expect.equals('alpha bravo', gauge.description);
33
34 Expect.throws(() {
35 // min > max.
36 gauge = new Gauge.range('test', 'alpha bravo', 2.0, 1.0);
37 });
38
39 Expect.throws(() {
40 // min == max.
41 gauge = new Gauge.range('test', 'alpha bravo', 1.0, 1.0);
42 });
43
44 Expect.throws(() {
45 // min is null
46 gauge = new Gauge.range('test', 'alpha bravo', null, 1.0);
47 });
48
49 Expect.throws(() {
50 // min is not a double
51 gauge = new Gauge.range('test', 'alpha bravo', 'string', 1.0);
52 });
53
54 Expect.throws(() {
55 // max is null
56 gauge = new Gauge.range('test', 'alpha bravo', 1.0, null);
57 });
58
59 Expect.throws(() {
60 // max is not a double
61 gauge = new Gauge.range('test', 'alpha bravo', 1.0, 4);
62 });
63 }
64
65 testCounter() {
66 var counter = new Counter('test', 'alpha bravo');
67 Expect.equals(0.0, counter.value);
68 Expect.equals('test', counter.name);
69 Expect.equals('alpha bravo', counter.description);
70 counter.value = 1.0;
71 Expect.equals(1.0, counter.value);
72 }
73
74 class CustomCounter extends Counter {
75 CustomCounter(name, description) : super(name, description);
76 // User provided getter.
77 double get value => 77.0;
78 }
79
80 testCustomCounter() {
81 var counter = new CustomCounter('test', 'alpha bravo');
82 Expect.equals(77.0, counter.value);
83 Expect.equals('test', counter.name);
84 Expect.equals('alpha bravo', counter.description);
85 // Should have no effect.
86 counter.value = 1.0;
87 Expect.equals(77.0, counter.value);
88 }
89
90 testMetricNameCollision() {
91 var counter = new Counter('a.b.c', 'alpha bravo charlie');
92 var counter2 = new Counter('a.b.c', 'alpha bravo charlie collider');
93 Metrics.register(counter);
94 Expect.throws(() {
95 Metrics.register(counter2);
96 });
97 Metrics.deregister(counter);
98 Metrics.register(counter);
99 var counter3 = new Counter('a.b.c.d', '');
100 Metrics.register(counter3);
101 }
102
103 testBadName() {
104 Expect.throws(() {
105 var counter = new Counter('a.b/c', 'description');
106 });
107 }
108
109 main() {
110 testGauge1();
111 testGauge2();
112 testCounter();
113 testCustomCounter();
114 testMetricNameCollision();
115 testBadName();
116 }
OLDNEW
« no previous file with comments | « sdk/lib/profiler/profiler.dart ('k') | tests/standalone/issue14236_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698