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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/usage/test/src/common.dart
diff --git a/packages/usage/test/src/common.dart b/packages/usage/test/src/common.dart
new file mode 100644
index 0000000000000000000000000000000000000000..44c99606bf7c3948f4cb0cc8acf4fedbe9648d32
--- /dev/null
+++ b/packages/usage/test/src/common.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library usage.common_test;
+
+import 'dart:async';
+
+import 'package:unittest/unittest.dart';
+import 'package:usage/src/usage_impl.dart';
+
+AnalyticsImplMock createMock({bool setOptIn: true}) =>
+ new AnalyticsImplMock('UA-0', setOptIn: setOptIn);
+
+void was(Map m, String type) => expect(m['t'], type);
+void has(Map m, String key) => expect(m[key], isNotNull);
+void hasnt(Map m, String key) => expect(m[key], isNull);
+
+class AnalyticsImplMock extends AnalyticsImpl {
+ MockProperties get mockProperties => properties;
+ MockPostHandler get mockPostHandler => postHandler;
+
+ AnalyticsImplMock(String trackingId, {bool setOptIn: true}) :
+ super(trackingId, new MockProperties(), new MockPostHandler(),
+ applicationName: 'Test App', applicationVersion: '0.1') {
+ if (setOptIn) optIn = true;
+ }
+
+ Map<String, dynamic> get last => mockPostHandler.last;
+}
+
+class MockProperties extends PersistentProperties {
+ Map<String, dynamic> props = {};
+
+ MockProperties() : super('mock');
+
+ dynamic operator[](String key) => props[key];
+
+ void operator[]=(String key, dynamic value) {
+ props[key] = value;
+ }
+}
+
+class MockPostHandler extends PostHandler {
+ List<Map> sentValues = [];
+
+ Future sendPost(String url, Map<String, String> parameters) {
+ sentValues.add(parameters);
+
+ return new Future.value();
+ }
+
+ Map<String, dynamic> get last => sentValues.last;
+}
« 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