This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e796b16
commit e328cc2
Showing
10 changed files
with
173 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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_test; | ||
|
||
import 'package:unittest/unittest.dart'; | ||
import 'package:usage/usage.dart'; | ||
|
||
void defineTests() { | ||
group('AnalyticsMock', () { | ||
test('simple', () { | ||
AnalyticsMock mock = new AnalyticsMock(); | ||
mock.sendScreenView('main'); | ||
mock.sendEvent('files', 'save'); | ||
mock.sendSocial('g+', 'plus', 'userid'); | ||
mock.sendTiming('compile', 123); | ||
mock.sendException('FooException'); | ||
mock.setSessionValue('val', 'ue'); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters