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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/service_test.cc ('K') | « runtime/vm/service_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/profiler/metrics_test.dart
diff --git a/tests/lib/profiler/metrics_test.dart b/tests/lib/profiler/metrics_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8ba066a4341283030a2babe29acd18bc364cc09b
--- /dev/null
+++ b/tests/lib/profiler/metrics_test.dart
@@ -0,0 +1,89 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+
+import 'dart:profiler';
+import 'package:expect/expect.dart';
+
+testGauge1() {
+ var gauge = new Gauge('test', 'alpha bravo', 0.0, 100.0);
+ Expect.equals(0.0, gauge.min);
+ Expect.equals(0.0, gauge.value);
+ Expect.equals(100.0, gauge.max);
+ Expect.equals('test', gauge.name);
+ Expect.equals('alpha bravo', gauge.description);
+ gauge.value = 44.0;
+ Expect.equals(44.0, gauge.value);
koda 2014/07/29 15:34:30 Test setting to out-of-range value.
Cutch 2014/07/29 18:27:01 Done.
+}
+
+testGauge2() {
+ var gauge = new Gauge('test', 'alpha bravo', 1.0, 2.0);
+ Expect.equals(1.0, gauge.min);
+ Expect.equals(2.0, gauge.max);
+ Expect.equals(gauge.min, gauge.value);
+ Expect.equals('test', gauge.name);
+ Expect.equals('alpha bravo', gauge.description);
+
+ Expect.throws(() {
+ // min > max.
+ gauge = new Gauge.range('test', 'alpha bravo', 2.0, 1.0);
+ });
+
+ Expect.throws(() {
+ // min == max.
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, 1.0);
+ });
+
+ Expect.throws(() {
+ // min is null
+ gauge = new Gauge.range('test', 'alpha bravo', null, 1.0);
+ });
+
+ Expect.throws(() {
+ // min is not a double
+ gauge = new Gauge.range('test', 'alpha bravo', 'string', 1.0);
+ });
+
+ Expect.throws(() {
+ // max is null
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, null);
+ });
+
+ Expect.throws(() {
+ // max is not a double
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, 4);
+ });
+}
+
+testCounter() {
+ var counter = new Counter('test', 'alpha bravo');
+ Expect.equals(0.0, counter.value);
+ Expect.equals('test', counter.name);
+ Expect.equals('alpha bravo', counter.description);
+ counter.value = 1.0;
+ Expect.equals(1.0, counter.value);
+}
+
+class CustomCounter extends Counter {
+ CustomCounter(name, description) : super(name, description);
+ // User provided getter.
+ double get value => 77.0;
+}
+
+testCustomCounter() {
+ var counter = new CustomCounter('test', 'alpha bravo');
+ Expect.equals(77.0, counter.value);
+ Expect.equals('test', counter.name);
+ Expect.equals('alpha bravo', counter.description);
+ // Should have no effect.
+ counter.value = 1.0;
+ Expect.equals(77.0, counter.value);
+}
+
+main() {
+ testGauge1();
+ testGauge2();
+ testCounter();
+ testCustomCounter();
+}
« runtime/vm/service_test.cc ('K') | « runtime/vm/service_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698