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 usage.usage_test; | 5 library usage.usage_test; |
6 | 6 |
7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
8 import 'package:usage/usage.dart'; | 8 import 'package:usage/usage.dart'; |
9 | 9 |
10 main() => defineTests(); | 10 main() => defineTests(); |
11 | 11 |
12 void defineTests() { | 12 void defineTests() { |
13 group('AnalyticsMock', () { | 13 group('AnalyticsMock', () { |
14 test('simple', () { | 14 test('simple', () { |
15 AnalyticsMock mock = new AnalyticsMock(); | 15 AnalyticsMock mock = new AnalyticsMock(); |
16 mock.sendScreenView('main'); | 16 mock.sendScreenView('main'); |
| 17 mock.sendScreenView('withParameters', parameters: {'cd1': 'custom'}); |
17 mock.sendEvent('files', 'save'); | 18 mock.sendEvent('files', 'save'); |
| 19 mock.sendEvent('eventWithParameters', 'save', |
| 20 parameters: {'cd1': 'custom'}); |
18 mock.sendSocial('g+', 'plus', 'userid'); | 21 mock.sendSocial('g+', 'plus', 'userid'); |
19 mock.sendTiming('compile', 123); | 22 mock.sendTiming('compile', 123); |
20 mock.startTimer('compile').finish(); | 23 mock.startTimer('compile').finish(); |
21 mock.sendException('FooException'); | 24 mock.sendException('FooException'); |
22 mock.setSessionValue('val', 'ue'); | 25 mock.setSessionValue('val', 'ue'); |
23 return mock.waitForLastPing(); | 26 return mock.waitForLastPing(); |
24 }); | 27 }); |
25 }); | 28 }); |
26 | 29 |
27 group('sanitizeStacktrace', () { | 30 group('sanitizeStacktrace', () { |
28 test('replace file', () { | 31 test('replace file', () { |
29 expect(sanitizeStacktrace( | 32 expect( |
30 '(file:///Users/foo/tmp/error.dart:3:13)', | 33 sanitizeStacktrace('(file:///Users/foo/tmp/error.dart:3:13)', |
31 shorten: false), | 34 shorten: false), |
32 '(error.dart:3:13)'); | 35 '(error.dart:3:13)'); |
33 }); | 36 }); |
34 | 37 |
35 test('replace files', () { | 38 test('replace files', () { |
36 expect(sanitizeStacktrace( | 39 expect( |
37 'foo (file:///Users/foo/tmp/error.dart:3:13)\n' | 40 sanitizeStacktrace( |
38 'bar (file:///Users/foo/tmp/error.dart:3:13)', | 41 'foo (file:///Users/foo/tmp/error.dart:3:13)\n' |
39 shorten: false), | 42 'bar (file:///Users/foo/tmp/error.dart:3:13)', |
| 43 shorten: false), |
40 'foo (error.dart:3:13)\nbar (error.dart:3:13)'); | 44 'foo (error.dart:3:13)\nbar (error.dart:3:13)'); |
41 }); | 45 }); |
42 | 46 |
43 test('shorten 1', () { | 47 test('shorten 1', () { |
44 expect(sanitizeStacktrace( | 48 expect(sanitizeStacktrace('(file:///Users/foo/tmp/error.dart:3:13)'), |
45 '(file:///Users/foo/tmp/error.dart:3:13)'), | |
46 '(error.dart:3:13)'); | 49 '(error.dart:3:13)'); |
47 }); | 50 }); |
48 | 51 |
49 test('shorten 2', () { | 52 test('shorten 2', () { |
50 expect(sanitizeStacktrace( | 53 expect( |
51 'foo (file:///Users/foo/tmp/error.dart:3:13)\n' | 54 sanitizeStacktrace('foo (file:///Users/foo/tmp/error.dart:3:13)\n' |
52 'bar (file:///Users/foo/tmp/error.dart:3:13)'), | 55 'bar (file:///Users/foo/tmp/error.dart:3:13)'), |
53 'foo (error.dart:3:13) bar (error.dart:3:13)'); | 56 'foo (error.dart:3:13)\nbar (error.dart:3:13)'); |
54 }); | 57 }); |
55 | 58 |
56 test('shorten 3', () { | 59 test('shorten 3', () { |
57 expect(sanitizeStacktrace( | 60 expect( |
58 'foo (package:foo/foo.dart:3:13)\n' | 61 sanitizeStacktrace('foo (package:foo/foo.dart:3:13)\n' |
59 'bar (dart:async/schedule_microtask.dart:41)'), | 62 'bar (dart:async/schedule_microtask.dart:41)'), |
60 'foo (foo/foo.dart:3:13) bar (async/schedule_microtask.dart:41)'); | 63 'foo (package:foo/foo.dart:3:13)\nbar (dart:async/schedule_microtask.d
art:41)'); |
61 }); | 64 }); |
62 }); | 65 }); |
63 } | 66 } |
OLD | NEW |