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

Unified Diff: packages/usage/test/usage_impl_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/usage/test/usage_impl_test.dart
diff --git a/packages/usage/test/usage_impl_test.dart b/packages/usage/test/usage_impl_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8601ceef83e6c4d983f4770ad4de990f9f860ff6
--- /dev/null
+++ b/packages/usage/test/usage_impl_test.dart
@@ -0,0 +1,71 @@
+// 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.
+
+library usage.impl_test;
+
+import 'package:unittest/unittest.dart';
+import 'package:usage/src/usage_impl.dart';
+
+import 'src/common.dart';
+
+void defineTests() {
+ group('ThrottlingBucket', () {
+ test('can send', () {
+ ThrottlingBucket bucket = new ThrottlingBucket(20);
+ expect(bucket.removeDrop(), true);
+ });
+
+ test('doesn\'t send too many', () {
+ ThrottlingBucket bucket = new ThrottlingBucket(20);
+ for (int i = 0; i < 20; i++) {
+ expect(bucket.removeDrop(), true);
+ }
+ expect(bucket.removeDrop(), false);
+ });
+ });
+
+ group('AnalyticsImpl', () {
+ test('respects disabled', () {
+ AnalyticsImplMock mock = createMock();
+ mock.optIn = false;
+ mock.sendException('FooBar exception');
+ expect(mock.optIn, false);
+ expect(mock.mockPostHandler.sentValues, isEmpty);
+ });
+
+ test('hasSetOptIn', () {
+ AnalyticsImplMock mock = createMock(setOptIn: false);
+ expect(mock.hasSetOptIn, false);
+ mock.optIn = false;
+ expect(mock.hasSetOptIn, true);
+ });
+
+ test('setSessionValue', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendScreenView('foo');
+ hasnt(mock.last, 'val');
+ mock.setSessionValue('val', 'ue');
+ mock.sendScreenView('bar');
+ has(mock.last, 'val');
+ mock.setSessionValue('val', null);
+ mock.sendScreenView('baz');
+ hasnt(mock.last, 'val');
+ });
+
+ test('waitForLastPing', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendScreenView('foo');
+ mock.sendScreenView('bar');
+ mock.sendScreenView('baz');
+ return mock.waitForLastPing(timeout: new Duration(milliseconds: 100));
+ });
+ });
+
+ group('postEncode', () {
+ test('simple', () {
+ Map map = {'foo': 'bar', 'baz': 'qux norf'};
+ expect(postEncode(map), 'foo=bar&baz=qux%20norf');
+ });
+ });
+}
« 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