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

Unified Diff: pkg/analysis_server/test/protocol_test.dart

Issue 865383002: add optional request field to record time at which client made request (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
Index: pkg/analysis_server/test/protocol_test.dart
diff --git a/pkg/analysis_server/test/protocol_test.dart b/pkg/analysis_server/test/protocol_test.dart
index e4bcb2168a4775fbe24005a6da0da203132ec7d6..544e9c5513f8e5d5d35fcd7c1254f678b59a53ca 100644
--- a/pkg/analysis_server/test/protocol_test.dart
+++ b/pkg/analysis_server/test/protocol_test.dart
@@ -149,6 +149,7 @@ class RequestTest {
Request request = new Request.fromString(json);
expect(request.id, equals('one'));
expect(request.method, equals('aMethod'));
+ expect(request.clientRequestTime, isNull);
}
void test_fromJson_invalidId() {
@@ -171,6 +172,28 @@ class RequestTest {
expect(request, isNull);
}
+ void test_fromJson_withBadClientTime() {
+ Request original = new Request('one', 'aMethod', null, 347);
+ Map<String, Object> map = original.toJson();
+ // Insert bad value - should be int but client sent string instead
+ map[Request.CLIENT_REQUEST_TIME] = '347';
+ String json = JSON.encode(map);
+ Request request = new Request.fromString(json);
+ expect(request.id, equals('one'));
+ expect(request.method, equals('aMethod'));
+ // Verify that bad value is ignored
Brian Wilkerson 2015/01/23 14:57:20 We should not ignore an invalid value. The field i
danrubel 2015/01/23 16:00:43 Good point. Done.
+ expect(request.clientRequestTime, isNull);
+ }
+
+ void test_fromJson_withClientTime() {
+ Request original = new Request('one', 'aMethod', null, 347);
+ String json = JSON.encode(original.toJson());
+ Request request = new Request.fromString(json);
+ expect(request.id, equals('one'));
+ expect(request.method, equals('aMethod'));
+ expect(request.clientRequestTime, 347);
+ }
+
void test_fromJson_withParams() {
Request original = new Request('one', 'aMethod', {
'foo': 'bar'
@@ -223,8 +246,7 @@ class ResponseTest {
}
void test_create_unanalyzedPriorityFiles() {
- Response response =
- new Response.unanalyzedPriorityFiles('0', 'file list');
+ Response response = new Response.unanalyzedPriorityFiles('0', 'file list');
expect(response.id, equals('0'));
expect(response.error, isNotNull);
expect(response.toJson(), equals({

Powered by Google App Engine
This is Rietveld 408576698