| OLD | NEW |
| 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 microlytics.test; | 5 library microlytics.test; |
| 6 | 6 |
| 7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
| 8 import 'package:microlytics/microlytics.dart'; | 8 import 'package:microlytics/microlytics.dart'; |
| 9 | 9 |
| 10 import 'test_channel.dart'; | 10 import 'test_channel.dart'; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 testBasicEventRead(); | 13 testBasicEventRead(); |
| 14 testBasicNegativeEventRead(); | 14 testBasicNegativeEventRead(); |
| 15 testBasicTimingRead(); | 15 testBasicTimingRead(); |
| 16 testBasicTimingMultiread(); | 16 testBasicTimingMultiread(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void testBasicEventRead() { | 19 void testBasicEventRead() { |
| 20 TestChannel c = new TestChannel(); | 20 TestChannel c = new TestChannel(); |
| 21 AnalyticsLogger logger = new AnalyticsLogger( | 21 AnalyticsLogger logger = new AnalyticsLogger( |
| 22 c, | 22 c, |
| 23 "2cfac780-31e2-11e4-8c21-0800200c9a66", | 23 "2cfac780-31e2-11e4-8c21-0800200c9a66", |
| 24 "UA-53895644-1", | 24 "UA-53895644-1", |
| 25 "TestApp", | 25 "TestApp", |
| 26 "0.42"); | 26 "0.42"); |
| 27 logger.logAnonymousEvent("video", "play"); | 27 logger.logAnonymousEvent("video", "play"); |
| 28 Expect.isTrue(c.contains( | 28 Expect.isTrue(c.contains("v=1" |
| 29 "v=1" | |
| 30 "&tid=UA-53895644-1" | 29 "&tid=UA-53895644-1" |
| 31 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 30 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 32 "&an=TestApp" | 31 "&an=TestApp" |
| 33 "&av=0.42" | 32 "&av=0.42" |
| 34 "&t=event" | 33 "&t=event" |
| 35 "&ec=video" | 34 "&ec=video" |
| 36 "&ea=play")); | 35 "&ea=play")); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void testBasicNegativeEventRead() { | 38 void testBasicNegativeEventRead() { |
| 40 TestChannel c = new TestChannel(); | 39 TestChannel c = new TestChannel(); |
| 41 AnalyticsLogger logger = new AnalyticsLogger( | 40 AnalyticsLogger logger = new AnalyticsLogger( |
| 42 c, | 41 c, |
| 43 "2cfac780-31e2-11e4-8c21-0800200c9a66", | 42 "2cfac780-31e2-11e4-8c21-0800200c9a66", |
| 44 "UA-53895644-1", | 43 "UA-53895644-1", |
| 45 "TestApp", | 44 "TestApp", |
| 46 "0.42"); | 45 "0.42"); |
| 47 logger.logAnonymousEvent("video", "play"); | 46 logger.logAnonymousEvent("video", "play"); |
| 48 Expect.isFalse(c.contains( | 47 Expect.isFalse(c.contains("v=1" |
| 49 "v=1" | 48 "&tid=UA-53895644-1" |
| 50 "&tid=UA-53895644-1" | 49 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 51 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 50 "&an=TestApp" |
| 52 "&an=TestApp" | 51 "&av=XXX" |
| 53 "&av=XXX" | 52 "&t=event" |
| 54 "&t=event" | 53 "&ec=video" |
| 55 "&ec=video" | 54 "&ea=play")); |
| 56 "&ea=play")); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 void testBasicTimingRead() { | 57 void testBasicTimingRead() { |
| 60 TestChannel c = new TestChannel(); | 58 TestChannel c = new TestChannel(); |
| 61 AnalyticsLogger logger = new AnalyticsLogger( | 59 AnalyticsLogger logger = new AnalyticsLogger( |
| 62 c, | 60 c, |
| 63 "2cfac780-31e2-11e4-8c21-0800200c9a66", | 61 "2cfac780-31e2-11e4-8c21-0800200c9a66", |
| 64 "UA-53895644-1", | 62 "UA-53895644-1", |
| 65 "TestApp", | 63 "TestApp", |
| 66 "0.42"); | 64 "0.42"); |
| 67 logger.logAnonymousTiming("video", "delay", 157); | 65 logger.logAnonymousTiming("video", "delay", 157); |
| 68 Expect.isTrue(c.contains( | 66 Expect.isTrue(c.contains("v=1" |
| 69 "v=1" | 67 "&tid=UA-53895644-1" |
| 70 "&tid=UA-53895644-1" | 68 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 71 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 69 "&an=TestApp" |
| 72 "&an=TestApp" | 70 "&av=0.42" |
| 73 "&av=0.42" | 71 "&t=timing" |
| 74 "&t=timing" | 72 "&utc=video" |
| 75 "&utc=video" | 73 "&utv=delay" |
| 76 "&utv=delay" | 74 "&utt=157")); |
| 77 "&utt=157")); | |
| 78 } | 75 } |
| 79 | 76 |
| 80 void testBasicTimingMultiread() { | 77 void testBasicTimingMultiread() { |
| 81 TestChannel c = new TestChannel(); | 78 TestChannel c = new TestChannel(); |
| 82 AnalyticsLogger logger = new AnalyticsLogger( | 79 AnalyticsLogger logger = new AnalyticsLogger( |
| 83 c, | 80 c, |
| 84 "2cfac780-31e2-11e4-8c21-0800200c9a66", | 81 "2cfac780-31e2-11e4-8c21-0800200c9a66", |
| 85 "UA-53895644-1", | 82 "UA-53895644-1", |
| 86 "TestApp", | 83 "TestApp", |
| 87 "0.42"); | 84 "0.42"); |
| 88 logger.logAnonymousTiming("video", "delay", 159); | 85 logger.logAnonymousTiming("video", "delay", 159); |
| 89 logger.logAnonymousTiming("video", "delay", 152); | 86 logger.logAnonymousTiming("video", "delay", 152); |
| 90 Expect.isTrue(c.contains( | 87 Expect.isTrue(c.contains("v=1" |
| 91 "v=1" | 88 "&tid=UA-53895644-1" |
| 92 "&tid=UA-53895644-1" | 89 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 93 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 90 "&an=TestApp" |
| 94 "&an=TestApp" | 91 "&av=0.42" |
| 95 "&av=0.42" | 92 "&t=timing" |
| 96 "&t=timing" | 93 "&utc=video" |
| 97 "&utc=video" | 94 "&utv=delay" |
| 98 "&utv=delay" | 95 "&utt=152")); |
| 99 "&utt=152")); | 96 Expect.isTrue(c.contains("v=1" |
| 100 Expect.isTrue(c.contains( | 97 "&tid=UA-53895644-1" |
| 101 "v=1" | 98 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 102 "&tid=UA-53895644-1" | 99 "&an=TestApp" |
| 103 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 100 "&av=0.42" |
| 104 "&an=TestApp" | 101 "&t=timing" |
| 105 "&av=0.42" | 102 "&utc=video" |
| 106 "&t=timing" | 103 "&utv=delay" |
| 107 "&utc=video" | 104 "&utt=159")); |
| 108 "&utv=delay" | 105 Expect.isFalse(c.contains("v=1" |
| 109 "&utt=159")); | 106 "&tid=UA-53895644-1" |
| 110 Expect.isFalse(c.contains( | 107 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" |
| 111 "v=1" | 108 "&an=TestApp" |
| 112 "&tid=UA-53895644-1" | 109 "&av=0.42" |
| 113 "&cid=2cfac780-31e2-11e4-8c21-0800200c9a66" | 110 "&t=timing" |
| 114 "&an=TestApp" | 111 "&utc=video" |
| 115 "&av=0.42" | 112 "&utv=delay" |
| 116 "&t=timing" | 113 "&utt=19")); |
| 117 "&utc=video" | 114 } |
| 118 "&utv=delay" | |
| 119 "&utt=19")); | |
| 120 } | |
| OLD | NEW |