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

Unified Diff: packages/usage/test/usage_impl_io_test.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/src/common.dart ('k') | packages/usage/test/usage_impl_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/usage/test/usage_impl_io_test.dart
diff --git a/packages/usage/test/usage_impl_io_test.dart b/packages/usage/test/usage_impl_io_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a0eec18d99d9961890daea0d6f5f9e213a618fef
--- /dev/null
+++ b/packages/usage/test/usage_impl_io_test.dart
@@ -0,0 +1,74 @@
+// 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.usage_impl_io_test;
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:unittest/unittest.dart';
+import 'package:usage/src/usage_impl_io.dart';
+
+void defineTests() {
+ group('IOPostHandler', () {
+ test('sendPost', () {
+ var httpClient = new MockHttpClient();
+ IOPostHandler postHandler = new IOPostHandler(mockClient: httpClient);
+ Map args = {'utv': 'varName', 'utt': 123};
+ return postHandler.sendPost('http://www.google.com', args).then((_) {
+ expect(httpClient.sendCount, 1);
+ });
+ });
+ });
+
+ group('IOPersistentProperties', () {
+ test('add', () {
+ IOPersistentProperties props = new IOPersistentProperties('foo_props');
+ props['foo'] = 'bar';
+ expect(props['foo'], 'bar');
+ });
+
+ test('remove', () {
+ IOPersistentProperties props = new IOPersistentProperties('foo_props');
+ props['foo'] = 'bar';
+ expect(props['foo'], 'bar');
+ props['foo'] = null;
+ expect(props['foo'], null);
+ });
+ });
+}
+
+class MockHttpClient implements HttpClient {
+ String userAgent;
+ int sendCount = 0;
+ int writeCount = 0;
+ bool closed = false;
+ Future<HttpClientRequest> postUrl(Uri url) {
+ return new Future.value(new MockHttpClientRequest(this));
+ }
+ noSuchMethod(Invocation invocation) { }
+}
+
+class MockHttpClientRequest implements HttpClientRequest {
+ final MockHttpClient client;
+ MockHttpClientRequest(this.client);
+ void write(Object obj) {
+ client.writeCount++;
+ }
+ Future<HttpClientResponse> close() {
+ client.closed = true;
+ return new Future.value(new MockHttpClientResponse(client));
+ }
+ noSuchMethod(Invocation invocation) { }
+}
+
+class MockHttpClientResponse implements HttpClientResponse {
+ final MockHttpClient client;
+ MockHttpClientResponse(this.client);
+ Future drain([var futureValue]) {
+ client.sendCount++;
+ return new Future.value();
+ }
+ noSuchMethod(Invocation invocation) { }
+}
« no previous file with comments | « packages/usage/test/src/common.dart ('k') | packages/usage/test/usage_impl_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698