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

Side by Side Diff: packages/usage/test/src/common.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « packages/usage/test/hit_types_test.dart ('k') | packages/usage/test/usage_impl_io_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 usage.common_test;
6
7 import 'dart:async';
8
9 import 'package:unittest/unittest.dart';
10 import 'package:usage/src/usage_impl.dart';
11
12 AnalyticsImplMock createMock({bool setOptIn: true}) =>
13 new AnalyticsImplMock('UA-0', setOptIn: setOptIn);
14
15 void was(Map m, String type) => expect(m['t'], type);
16 void has(Map m, String key) => expect(m[key], isNotNull);
17 void hasnt(Map m, String key) => expect(m[key], isNull);
18
19 class AnalyticsImplMock extends AnalyticsImpl {
20 MockProperties get mockProperties => properties;
21 MockPostHandler get mockPostHandler => postHandler;
22
23 AnalyticsImplMock(String trackingId, {bool setOptIn: true}) :
24 super(trackingId, new MockProperties(), new MockPostHandler(),
25 applicationName: 'Test App', applicationVersion: '0.1') {
26 if (setOptIn) optIn = true;
27 }
28
29 Map<String, dynamic> get last => mockPostHandler.last;
30 }
31
32 class MockProperties extends PersistentProperties {
33 Map<String, dynamic> props = {};
34
35 MockProperties() : super('mock');
36
37 dynamic operator[](String key) => props[key];
38
39 void operator[]=(String key, dynamic value) {
40 props[key] = value;
41 }
42 }
43
44 class MockPostHandler extends PostHandler {
45 List<Map> sentValues = [];
46
47 Future sendPost(String url, Map<String, String> parameters) {
48 sentValues.add(parameters);
49
50 return new Future.value();
51 }
52
53 Map<String, dynamic> get last => sentValues.last;
54 }
OLDNEW
« no previous file with comments | « packages/usage/test/hit_types_test.dart ('k') | packages/usage/test/usage_impl_io_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698