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

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

Issue 376693002: Extract testing utilities into a separate package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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/abstract_context.dart
diff --git a/pkg/analysis_server/test/abstract_context.dart b/pkg/analysis_server/test/abstract_context.dart
deleted file mode 100644
index f7ac28625059aa22782060a88fd9676f15d8112e..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/test/abstract_context.dart
+++ /dev/null
@@ -1,89 +0,0 @@
-// 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 test.index;
-
-import 'package:analyzer/file_system/file_system.dart';
-import 'package:analyzer/file_system/memory_file_system.dart';
-import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/element.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/sdk.dart';
-import 'package:analyzer/src/generated/source_io.dart';
-
-import 'mocks.dart';
-import 'reflective_tests.dart';
-
-
-/**
- * Finds an [engine.Element] with the given [name].
- */
-Element findElementInUnit(CompilationUnit unit, String name, [ElementKind kind])
- {
- Element result = null;
- unit.element.accept(new _ElementVisitorFunctionWrapper((Element element) {
- if (element.name != name) {
- return;
- }
- if (kind != null && element.kind != kind) {
- return;
- }
- result = element;
- }));
- return result;
-}
-
-
-/**
- * A function to be called for every [Element].
- */
-typedef void _ElementVisitorFunction(Element element);
-
-
-@ReflectiveTestCase()
-class AbstractContextTest {
- static final DartSdk SDK = new MockSdk();
-
- AnalysisContext context;
- MemoryResourceProvider provider = new MemoryResourceProvider();
-
- Source addSource(String path, String content) {
- File file = provider.newFile(path, content);
- Source source = file.createSource(UriKind.FILE_URI);
- ChangeSet changeSet = new ChangeSet();
- changeSet.addedSource(source);
- context.applyChanges(changeSet);
- context.setContents(source, content);
- return source;
- }
-
- CompilationUnit resolveLibraryUnit(Source source) {
- return context.resolveCompilationUnit2(source, source);
- }
-
- void setUp() {
- context = AnalysisEngine.instance.createAnalysisContext();
- context.sourceFactory = new SourceFactory(<UriResolver>[new DartUriResolver(
- SDK), new ResourceUriResolver(provider)]);
- }
-
- void tearDown() {
- context = null;
- provider = null;
- }
-}
-
-
-/**
- * Wraps the given [_ElementVisitorFunction] into an instance of
- * [engine.GeneralizingElementVisitor].
- */
-class _ElementVisitorFunctionWrapper extends GeneralizingElementVisitor {
- final _ElementVisitorFunction function;
- _ElementVisitorFunctionWrapper(this.function);
- visitElement(Element element) {
- function(element);
- super.visitElement(element);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698