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