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

Unified Diff: packages/analyzer/test/src/task/general_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/analyzer/test/src/task/driver_test.dart ('k') | packages/analyzer/test/src/task/html_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/analyzer/test/src/task/general_test.dart
diff --git a/packages/analyzer/test/src/task/general_test.dart b/packages/analyzer/test/src/task/general_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b335664f773ec0b8578a815b5480fbec4074feb4
--- /dev/null
+++ b/packages/analyzer/test/src/task/general_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2015, 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 test.src.task.general_test;
+
+import 'package:analyzer/src/generated/engine.dart'
+ hide AnalysisTask, GetContentTask;
+import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer/src/task/general.dart';
+import 'package:analyzer/task/general.dart';
+import 'package:analyzer/task/model.dart';
+import 'package:typed_mock/typed_mock.dart';
+import 'package:unittest/unittest.dart';
+
+import '../../generated/test_support.dart';
+import '../../reflective_tests.dart';
+import '../../utils.dart';
+
+main() {
+ initializeTestEnvironment();
+ runReflectiveTests(GetContentTaskTest);
+}
+
+@reflectiveTest
+class GetContentTaskTest extends EngineTestCase {
+ test_buildInputs() {
+ AnalysisTarget target = new TestSource();
+ Map<String, TaskInput> inputs = GetContentTask.buildInputs(target);
+ expect(inputs, isEmpty);
+ }
+
+ test_constructor() {
+ AnalysisContext context = new _MockContext();
+ AnalysisTarget target = new TestSource();
+ GetContentTask task = new GetContentTask(context, target);
+ expect(task, isNotNull);
+ expect(task.context, context);
+ expect(task.target, target);
+ }
+
+ test_createTask() {
+ AnalysisContext context = new _MockContext();
+ AnalysisTarget target = new TestSource();
+ GetContentTask task = GetContentTask.createTask(context, target);
+ expect(task, isNotNull);
+ expect(task.context, context);
+ expect(task.target, target);
+ }
+
+ test_descriptor() {
+ AnalysisContext context = new _MockContext();
+ AnalysisTarget target = new TestSource();
+ GetContentTask task = new GetContentTask(context, target);
+ expect(task.descriptor, GetContentTask.DESCRIPTOR);
+ }
+
+ test_perform() {
+ AnalysisContext context = new _MockContext();
+ Source target = new TestSource();
+ GetContentTask task = new GetContentTask(context, target);
+ when(context.getContents(target))
+ .thenReturn(new TimestampedData<String>(42, 'foo'));
+ task.perform();
+ expect(task.caughtException, isNull);
+ expect(task.outputs, hasLength(2));
+ expect(task.outputs[CONTENT], 'foo');
+ expect(task.outputs[MODIFICATION_TIME], 42);
+ }
+
+ void test_perform_exception() {
+ AnalysisContext context = new _MockContext();
+ Source target = new TestSource();
+ GetContentTask task = new GetContentTask(context, target);
+ when(context.getContents(target)).thenThrow('My exception!');
+ task.perform();
+ expect(task.caughtException, isNull);
+ expect(task.outputs, hasLength(2));
+ expect(task.outputs[CONTENT], '');
+ expect(task.outputs[MODIFICATION_TIME], -1);
+ }
+}
+
+class _MockContext extends TypedMock implements AnalysisContext {
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
« no previous file with comments | « packages/analyzer/test/src/task/driver_test.dart ('k') | packages/analyzer/test/src/task/html_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698