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 library usage.hit_types_test; | 5 library usage.hit_types_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
| 9 import 'package:test/test.dart'; |
9 import 'package:usage/usage.dart'; | 10 import 'package:usage/usage.dart'; |
10 import 'package:unittest/unittest.dart'; | |
11 | 11 |
12 import 'src/common.dart'; | 12 import 'src/common.dart'; |
13 | 13 |
| 14 main() => defineTests(); |
| 15 |
14 void defineTests() { | 16 void defineTests() { |
15 group('screenView', () { | 17 group('screenView', () { |
16 test('simple', () { | 18 test('simple', () { |
17 AnalyticsImplMock mock = createMock(); | 19 AnalyticsImplMock mock = createMock(); |
18 mock.sendScreenView('main'); | 20 mock.sendScreenView('main'); |
19 expect(mock.mockProperties['clientId'], isNotNull); | 21 expect(mock.mockProperties['clientId'], isNotNull); |
20 expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); | 22 expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
21 }); | 23 }); |
22 }); | 24 }); |
23 | 25 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 has(mock.last, 'utt'); | 76 has(mock.last, 'utt'); |
75 has(mock.last, 'utc'); | 77 has(mock.last, 'utc'); |
76 has(mock.last, 'utl'); | 78 has(mock.last, 'utl'); |
77 }); | 79 }); |
78 | 80 |
79 test('timer', () { | 81 test('timer', () { |
80 AnalyticsImplMock mock = createMock(); | 82 AnalyticsImplMock mock = createMock(); |
81 AnalyticsTimer timer = | 83 AnalyticsTimer timer = |
82 mock.startTimer('compile', category: 'Build', label: 'Compile'); | 84 mock.startTimer('compile', category: 'Build', label: 'Compile'); |
83 | 85 |
84 int time; | |
85 | |
86 return new Future.delayed(new Duration(milliseconds: 20), () { | 86 return new Future.delayed(new Duration(milliseconds: 20), () { |
87 return timer.finish().then((_) { | 87 return timer.finish().then((_) { |
88 expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); | 88 expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
89 was(mock.last, 'timing'); | 89 was(mock.last, 'timing'); |
90 has(mock.last, 'utv'); | 90 has(mock.last, 'utv'); |
91 has(mock.last, 'utt'); | 91 has(mock.last, 'utt'); |
92 has(mock.last, 'utc'); | 92 has(mock.last, 'utc'); |
93 has(mock.last, 'utl'); | 93 has(mock.last, 'utl'); |
94 int time = timer.currentElapsedMillis; | 94 int time = timer.currentElapsedMillis; |
95 expect(time, greaterThan(10)); | 95 expect(time, greaterThan(10)); |
(...skipping 30 matching lines...) Expand all Loading... |
126 }); | 126 }); |
127 | 127 |
128 test('long description trimmed', () { | 128 test('long description trimmed', () { |
129 String str = '0123456789abcdefghijklmnopqrstuvwxyz'; | 129 String str = '0123456789abcdefghijklmnopqrstuvwxyz'; |
130 AnalyticsImplMock mock = createMock(); | 130 AnalyticsImplMock mock = createMock(); |
131 mock.sendException(str + str + str + str + str); | 131 mock.sendException(str + str + str + str + str); |
132 expect(mock.last['exd'].length, 100); | 132 expect(mock.last['exd'].length, 100); |
133 }); | 133 }); |
134 }); | 134 }); |
135 } | 135 } |
OLD | NEW |