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