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

Side by Side Diff: third_party/pkg/perf_api/test/perf_api_test.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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
OLDNEW
(Empty)
1 library perf_api.noop_test;
2
3 import 'dart:async';
4
5 import 'package:unittest/unittest.dart';
6 import 'package:perf_api/perf_api.dart';
7
8 main() {
9
10 test('should be able to instantiate as a noop profiler', () {
11 expect(() => new Profiler(), returnsNormally);
12 });
13
14 group('Default Impl', () {
15 Profiler perf;
16
17 setUp(() {
18 perf = new Profiler();
19 });
20
21 test('should do noop startTimer', () {
22 expect(() => perf.startTimer('foo', 'bar'), returnsNormally);
23 });
24
25 test('should do noop stopTimer', () {
26 expect(() => perf.stopTimer('foo'), returnsNormally);
27 });
28
29 test('should do noop start/stopTimer', () {
30 expect(() {
31 var timerId = perf.startTimer('foo');
32 perf.stopTimer(timerId);
33 }, returnsNormally);
34 });
35
36 test('should do noop markTime', () {
37 expect(() => perf.markTime('foo'), returnsNormally);
38 });
39
40 test('should do noop time function', () {
41 expect(() => perf.time('foo', () {}, 'bar'), returnsNormally);
42 });
43
44 test('should do noop time future', () {
45 expect(() {
46 perf.time('foo', new Future.sync(() => null), 'bar');
47 }, returnsNormally);
48 });
49
50 group('counters', () {
51
52 test('should return null for uninitialized counter', () {
53 expect(perf.counters['foo'], null);
54 });
55
56 test('should increment counter', () {
57 perf.counters.increment('foo');
58 expect(perf.counters['foo'], 1);
59 });
60
61 test('should increment counter by given delta', () {
62 perf.counters.increment('foo', 10);
63 expect(perf.counters['foo'], 10);
64 perf.counters.increment('foo', 5);
65 expect(perf.counters['foo'], 15);
66 });
67
68 test('should set counter to provided value', () {
69 perf.counters['foo'] = 10;
70 expect(perf.counters['foo'], 10);
71 });
72
73 test('should decrement counter when delta is negative', () {
74 perf.counters['foo'] = 15;
75 perf.counters.increment('foo', -10);
76 expect(perf.counters['foo'], 5);
77 });
78
79 test('should allow negative counter values', () {
80 perf.counters['foo'] = 10;
81 perf.counters.increment('foo', -15);
82 expect(perf.counters['foo'], -5);
83 });
84
85 test('should return counters map', () {
86 perf.counters['foo'] = 1;
87 perf.counters.increment('bar', 2);
88 perf.counters['baz'] = 3;
89 expect(perf.counters.all, {
90 'foo': 1,
91 'bar': 2,
92 'baz': 3
93 });
94 });
95
96 test('should return immutable counters map', () {
97 expect(() => perf.counters.all['foo'] = 0,
98 throwsA(new isInstanceOf<UnsupportedError>()));
99 expect(() => perf.counters.all.putIfAbsent('foo', () => 0),
100 throwsA(new isInstanceOf<UnsupportedError>()));
101 expect(() => perf.counters.all.remove('foo'),
102 throwsA(new isInstanceOf<UnsupportedError>()));
103 expect(() => perf.counters.all.clear(),
104 throwsA(new isInstanceOf<UnsupportedError>()));
105 expect(() => perf.counters.all.addAll({}),
106 throwsA(new isInstanceOf<UnsupportedError>()));
107 });
108
109 });
110 });
111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698