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

Unified Diff: microlytics/test/dart_microlytics_test.dart

Issue 515993003: Minimalistic analytics library used by Dart Server and try.dartlang.org (Closed) Base URL: https://github.com/lukechurch/dart-mircolytics.git@master
Patch Set: Address review comments Created 6 years, 3 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
Index: microlytics/test/dart_microlytics_test.dart
diff --git a/microlytics/test/dart_microlytics_test.dart b/microlytics/test/dart_microlytics_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5a3f9a6ca8fa62afc385a89452eb5db7f31a3e57
--- /dev/null
+++ b/microlytics/test/dart_microlytics_test.dart
@@ -0,0 +1,113 @@
+// 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 microlytics.test;
+
+import 'package:unittest/unittest.dart';
ahe 2014/09/03 08:51:31 Still not a fan.
lukechurch 2014/09/04 12:58:42 Removed.
+import '../lib/microlytics.dart';
+import 'test_channel.dart';
+
+void main() {
+ test('Basic event readtest', () {
+ TestChannel c = new TestChannel();
+ AnalyticsLogger logger = new AnalyticsLogger(
+ c,
+ "2cfac780-31e2-11e4-8c21-0800200c9a66",
+ "UA-53895644-1",
+ "TestApp",
+ "0.42");
+ logger.logAnonymousEvent("video", "play");
+ expect(true, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=0.42"
+ "&t=event"
+ "&ec=video"
+ "&ea=play"));
+ });
+
+ test('Basic negative event readtest', () {
+ TestChannel c = new TestChannel();
+ AnalyticsLogger logger = new AnalyticsLogger(
+ c,
+ "2cfac780-31e2-11e4-8c21-0800200c9a66",
+ "UA-53895644-1",
+ "TestApp",
+ "0.42");
+ logger.logAnonymousEvent("video", "play");
+ expect(false, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=XXX"
+ "&t=event"
+ "&ec=video"
+ "&ea=play"));
+ });
+
+ test('Basic timing readtest', () {
+ TestChannel c = new TestChannel();
+ AnalyticsLogger logger = new AnalyticsLogger(
+ c,
+ "2cfac780-31e2-11e4-8c21-0800200c9a66",
+ "UA-53895644-1",
+ "TestApp",
+ "0.42");
+ logger.logAnonymousTiming("video", "delay", 157);
+ expect(true, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=0.42"
+ "&t=timing"
+ "&utc=video"
+ "&utv=delay"
+ "&utt=157"));
+ });
+
+ test('Basic timing multi readtest', () {
+ TestChannel c = new TestChannel();
+ AnalyticsLogger logger = new AnalyticsLogger(
+ c,
+ "2cfac780-31e2-11e4-8c21-0800200c9a66",
+ "UA-53895644-1",
+ "TestApp",
+ "0.42");
+ logger.logAnonymousTiming("video", "delay", 159);
+ logger.logAnonymousTiming("video", "delay", 152);
+ expect(true, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=0.42"
+ "&t=timing"
+ "&utc=video"
+ "&utv=delay"
+ "&utt=152"));
+ expect(true, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=0.42"
+ "&t=timing"
+ "&utc=video"
+ "&utv=delay"
+ "&utt=159"));
+ expect(false, c.contains(
+ "v=1"
+ "&tid=UA-53895644-1"
+ "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
+ "&an=TestApp"
+ "&av=0.42"
+ "&t=timing"
+ "&utc=video"
+ "&utv=delay"
+ "&utt=19"));
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698