Index: packages/usage/test/hit_types_test.dart |
diff --git a/packages/usage/test/hit_types_test.dart b/packages/usage/test/hit_types_test.dart |
index 4bfb608b772815cfc2000789ba6537b5c7966bb2..e8bf241c2d845a462bd1a6ba5700865992690086 100644 |
--- a/packages/usage/test/hit_types_test.dart |
+++ b/packages/usage/test/hit_types_test.dart |
@@ -21,6 +21,13 @@ void defineTests() { |
expect(mock.mockProperties['clientId'], isNotNull); |
expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
}); |
+ test('with parameters', () { |
+ AnalyticsImplMock mock = createMock(); |
+ mock.sendScreenView('withParams', parameters: {'cd1': 'foo'}); |
+ expect(mock.mockProperties['clientId'], isNotNull); |
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
+ has(mock.last, 'cd1'); |
+ }); |
}); |
group('event', () { |
@@ -33,6 +40,16 @@ void defineTests() { |
has(mock.last, 'ea'); |
}); |
+ test('with parameters', () { |
+ AnalyticsImplMock mock = createMock(); |
+ mock.sendEvent('withParams', 'save', parameters: {'cd1': 'foo'}); |
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
+ was(mock.last, 'event'); |
+ has(mock.last, 'ec'); |
+ has(mock.last, 'ea'); |
+ has(mock.last, 'cd1'); |
+ }); |
+ |
test('optional args', () { |
AnalyticsImplMock mock = createMock(); |
mock.sendEvent('files', 'save', label: 'File Save', value: 23); |
@@ -78,26 +95,25 @@ void defineTests() { |
has(mock.last, 'utl'); |
}); |
- test('timer', () { |
+ test('timer', () async { |
AnalyticsImplMock mock = createMock(); |
AnalyticsTimer timer = |
mock.startTimer('compile', category: 'Build', label: 'Compile'); |
- return new Future.delayed(new Duration(milliseconds: 20), () { |
- return timer.finish().then((_) { |
- expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
- was(mock.last, 'timing'); |
- has(mock.last, 'utv'); |
- has(mock.last, 'utt'); |
- has(mock.last, 'utc'); |
- has(mock.last, 'utl'); |
- int time = timer.currentElapsedMillis; |
- expect(time, greaterThan(10)); |
- return new Future.delayed(new Duration(milliseconds: 10), () { |
- expect(timer.currentElapsedMillis, time); |
- }); |
- }); |
- }); |
+ await new Future.delayed(new Duration(milliseconds: 20)); |
+ |
+ await timer.finish(); |
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty)); |
+ was(mock.last, 'timing'); |
+ has(mock.last, 'utv'); |
+ has(mock.last, 'utt'); |
+ has(mock.last, 'utc'); |
+ has(mock.last, 'utl'); |
+ int time = timer.currentElapsedMillis; |
+ expect(time, greaterThan(10)); |
+ |
+ await new Future.delayed(new Duration(milliseconds: 10)); |
+ expect(timer.currentElapsedMillis, time); |
}); |
}); |
@@ -124,12 +140,5 @@ void defineTests() { |
mock.sendException('foo bar (file:///Users/foobar/tmp/error.dart:3:13)'); |
expect(mock.last['exd'], 'foo bar ('); |
}); |
- |
- test('long description trimmed', () { |
- String str = '0123456789abcdefghijklmnopqrstuvwxyz'; |
- AnalyticsImplMock mock = createMock(); |
- mock.sendException(str + str + str + str + str); |
- expect(mock.last['exd'].length, 100); |
- }); |
}); |
} |