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

Unified Diff: packages/usage/test/hit_types_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/all.dart ('k') | packages/usage/test/src/common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..6cfa321bfbd2ab732efd08ab321439fbb5daf650
--- /dev/null
+++ b/packages/usage/test/hit_types_test.dart
@@ -0,0 +1,135 @@
+// 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.hit_types_test;
+
+import 'dart:async';
+
+import 'package:usage/usage.dart';
+import 'package:unittest/unittest.dart';
+
+import 'src/common.dart';
+
+void defineTests() {
+ group('screenView', () {
+ test('simple', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendScreenView('main');
+ expect(mock.mockProperties['clientId'], isNotNull);
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ });
+ });
+
+ group('event', () {
+ test('simple', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendEvent('files', 'save');
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'event');
+ has(mock.last, 'ec');
+ has(mock.last, 'ea');
+ });
+
+ test('optional args', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendEvent('files', 'save', label: 'File Save', value: 23);
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'event');
+ has(mock.last, 'ec');
+ has(mock.last, 'ea');
+ has(mock.last, 'el');
+ has(mock.last, 'ev');
+ });
+ });
+
+ group('social', () {
+ test('simple', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendSocial('g+', 'plus', 'userid');
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'social');
+ has(mock.last, 'sn');
+ has(mock.last, 'st');
+ has(mock.last, 'sa');
+ });
+ });
+
+ group('timing', () {
+ test('simple', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendTiming('compile', 123);
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'timing');
+ has(mock.last, 'utv');
+ has(mock.last, 'utt');
+ });
+
+ test('optional args', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendTiming('compile', 123, category: 'Build', label: 'Compile');
+ 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');
+ });
+
+ test('timer', () {
+ AnalyticsImplMock mock = createMock();
+ AnalyticsTimer timer =
+ mock.startTimer('compile', category: 'Build', label: 'Compile');
+
+ int time;
+
+ 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);
+ });
+ });
+ });
+ });
+ });
+
+ group('exception', () {
+ test('simple', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendException('FooException');
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'exception');
+ has(mock.last, 'exd');
+ });
+
+ test('optional args', () {
+ AnalyticsImplMock mock = createMock();
+ mock.sendException('FooException', fatal: true);
+ expect(mock.mockPostHandler.sentValues, isNot(isEmpty));
+ was(mock.last, 'exception');
+ has(mock.last, 'exd');
+ has(mock.last, 'exf');
+ });
+
+ test('exception file paths', () {
+ AnalyticsImplMock mock = createMock();
+ 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);
+ });
+ });
+}
« no previous file with comments | « packages/usage/test/all.dart ('k') | packages/usage/test/src/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698