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

Side by Side Diff: packages/usage/test/usage_impl_test.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 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
« no previous file with comments | « packages/usage/test/usage_impl_io_test.dart ('k') | packages/usage/test/usage_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
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.impl_test; 5 library usage.impl_test;
6 6
7 import 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 import 'package:usage/src/usage_impl.dart'; 8 import 'package:usage/src/usage_impl.dart';
9 9
10 import 'src/common.dart'; 10 import 'src/common.dart';
(...skipping 10 matching lines...) Expand all
21 test('doesn\'t send too many', () { 21 test('doesn\'t send too many', () {
22 ThrottlingBucket bucket = new ThrottlingBucket(20); 22 ThrottlingBucket bucket = new ThrottlingBucket(20);
23 for (int i = 0; i < 20; i++) { 23 for (int i = 0; i < 20; i++) {
24 expect(bucket.removeDrop(), true); 24 expect(bucket.removeDrop(), true);
25 } 25 }
26 expect(bucket.removeDrop(), false); 26 expect(bucket.removeDrop(), false);
27 }); 27 });
28 }); 28 });
29 29
30 group('AnalyticsImpl', () { 30 group('AnalyticsImpl', () {
31 test('trackingId', () {
32 AnalyticsImplMock mock = createMock();
33 expect(mock.trackingId, isNotNull);
34 });
35
36 test('applicationName', () {
37 AnalyticsImplMock mock = createMock();
38 expect(mock.applicationName, isNotNull);
39 });
40
41 test('applicationVersion', () {
42 AnalyticsImplMock mock = createMock();
43 expect(mock.applicationVersion, isNotNull);
44 });
45
46 test('respects disabled', () { 31 test('respects disabled', () {
47 AnalyticsImplMock mock = createMock(); 32 AnalyticsImplMock mock = createMock();
48 mock.enabled = false; 33 mock.optIn = false;
49 mock.sendException('FooBar exception'); 34 mock.sendException('FooBar exception');
50 expect(mock.enabled, false); 35 expect(mock.optIn, false);
51 expect(mock.mockPostHandler.sentValues, isEmpty); 36 expect(mock.mockPostHandler.sentValues, isEmpty);
52 }); 37 });
53 38
54 test('firstRun', () { 39 test('hasSetOptIn', () {
55 AnalyticsImplMock mock = createMock(); 40 AnalyticsImplMock mock = createMock(setOptIn: false);
56 expect(mock.firstRun, true); 41 expect(mock.hasSetOptIn, false);
57 mock = createMock(props: {'firstRun': false}); 42 mock.optIn = false;
58 expect(mock.firstRun, false); 43 expect(mock.hasSetOptIn, true);
59 }); 44 });
60 45
61 test('setSessionValue', () { 46 test('setSessionValue', () {
62 AnalyticsImplMock mock = createMock(); 47 AnalyticsImplMock mock = createMock();
63 mock.sendScreenView('foo'); 48 mock.sendScreenView('foo');
64 hasnt(mock.last, 'val'); 49 hasnt(mock.last, 'val');
65 mock.setSessionValue('val', 'ue'); 50 mock.setSessionValue('val', 'ue');
66 mock.sendScreenView('bar'); 51 mock.sendScreenView('bar');
67 has(mock.last, 'val'); 52 has(mock.last, 'val');
68 mock.setSessionValue('val', null); 53 mock.setSessionValue('val', null);
69 mock.sendScreenView('baz'); 54 mock.sendScreenView('baz');
70 hasnt(mock.last, 'val'); 55 hasnt(mock.last, 'val');
71 }); 56 });
72 57
73 test('waitForLastPing', () { 58 test('waitForLastPing', () {
74 AnalyticsImplMock mock = createMock(); 59 AnalyticsImplMock mock = createMock();
75 mock.sendScreenView('foo'); 60 mock.sendScreenView('foo');
76 mock.sendScreenView('bar'); 61 mock.sendScreenView('bar');
77 mock.sendScreenView('baz'); 62 mock.sendScreenView('baz');
78 return mock.waitForLastPing(timeout: new Duration(milliseconds: 100)); 63 return mock.waitForLastPing(timeout: new Duration(milliseconds: 100));
79 }); 64 });
80
81 group('clientId', () {
82 test('is available immediately', () {
83 AnalyticsImplMock mock = createMock();
84 expect(mock.clientId, isNotEmpty);
85 });
86
87 test('is memoized', () {
88 AnalyticsImplMock mock = createMock();
89 final value1 = mock.clientId;
90 final value2 = mock.clientId;
91 expect(value1, isNotEmpty);
92 expect(value1, value2);
93 });
94
95 test('is stored in properties', () {
96 AnalyticsImplMock mock = createMock();
97 expect(mock.properties['clientId'], isNull);
98 final value = mock.clientId;
99 expect(mock.properties['clientId'], value);
100 });
101 });
102 }); 65 });
103 66
104 group('postEncode', () { 67 group('postEncode', () {
105 test('simple', () { 68 test('simple', () {
106 Map<String, dynamic> map = {'foo': 'bar', 'baz': 'qux norf'}; 69 Map<String, dynamic> map = {'foo': 'bar', 'baz': 'qux norf'};
107 expect(postEncode(map), 'foo=bar&baz=qux%20norf'); 70 expect(postEncode(map), 'foo=bar&baz=qux%20norf');
108 }); 71 });
109 }); 72 });
110 } 73 }
OLDNEW
« no previous file with comments | « packages/usage/test/usage_impl_io_test.dart ('k') | packages/usage/test/usage_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698