fix(browser): platform code cleanup
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {document, window} from '../src/facade/browser';
|
||||
import {NumberWrapper, isBlank} from '../src/facade/lang';
|
||||
import {BaseException, WrappedException} from '../src/facade/exceptions';
|
||||
import {BaseException} from '../src/facade/exceptions';
|
||||
|
||||
var DOM = new BrowserDomAdapter();
|
||||
|
||||
|
@ -1,37 +1,35 @@
|
||||
import {
|
||||
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS
|
||||
} from './browser_static';
|
||||
import {BROWSER_APP_PROVIDERS} from '../index';
|
||||
import {DirectiveResolver, ViewResolver} from '@angular/compiler';
|
||||
import {TEST_BROWSER_STATIC_PLATFORM_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS} from "./browser_static";
|
||||
import {BROWSER_APP_PROVIDERS, BROWSER_APP_COMPILER_PROVIDERS} from "../index";
|
||||
import {DirectiveResolver, ViewResolver} from "@angular/compiler";
|
||||
import {
|
||||
MockDirectiveResolver,
|
||||
MockViewResolver,
|
||||
TestComponentRenderer,
|
||||
TestComponentBuilder
|
||||
} from '@angular/compiler/testing';
|
||||
import {DOMTestComponentRenderer} from './dom_test_component_renderer';
|
||||
} from "@angular/compiler/testing";
|
||||
import {DOMTestComponentRenderer} from "./dom_test_component_renderer";
|
||||
|
||||
/**
|
||||
* Default platform providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[TEST_BROWSER_STATIC_PLATFORM_PROVIDERS];
|
||||
[TEST_BROWSER_STATIC_PLATFORM_PROVIDERS];
|
||||
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_PROVIDERS = [
|
||||
/*@ts2dart_Provider*/ {provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
/*@ts2dart_Provider*/ {provide: ViewResolver, useClass: MockViewResolver},
|
||||
{provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
||||
{provide: ViewResolver, useClass: MockViewResolver},
|
||||
TestComponentBuilder,
|
||||
/*@ts2dart_Provider*/ {provide: TestComponentRenderer, useClass: DOMTestComponentRenderer},
|
||||
{provide: TestComponentRenderer, useClass: DOMTestComponentRenderer},
|
||||
];
|
||||
|
||||
/**
|
||||
* Default application providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
[
|
||||
BROWSER_APP_PROVIDERS,
|
||||
BROWSER_APP_COMPILER_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
];
|
||||
|
@ -1,15 +1,38 @@
|
||||
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
||||
import {BROWSER_APP_COMMON_PROVIDERS} from '../src/platform/common/browser';
|
||||
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
||||
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
||||
import {AnimationBuilder} from '../src/animate/animation_builder';
|
||||
import {MockAnimationBuilder} from './animation_builder_mock';
|
||||
import {MockLocationStrategy} from '@angular/common/testing';
|
||||
import {LocationStrategy} from '@angular/common';
|
||||
import {MockNgZone} from '@angular/core/testing';
|
||||
import {BrowserDetection} from './browser_util';
|
||||
import {Log} from '@angular/core/testing';
|
||||
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
||||
import {IS_DART} from '../src/facade/lang';
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[
|
||||
{provide: APP_ID, useValue: 'a'},
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
Log,
|
||||
{provide: NgZone, useFactory: createNgZone},
|
||||
{provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
{provide: AnimationBuilder, useClass: MockAnimationBuilder}
|
||||
];
|
||||
|
||||
/**
|
||||
* Default application providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
[BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|
||||
|
||||
function initBrowserTests() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
@ -17,30 +40,5 @@ function initBrowserTests() {
|
||||
}
|
||||
|
||||
function createNgZone(): NgZone {
|
||||
return IS_DART ? new MockNgZone() : new NgZone({enableLongStackTrace: true});
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
||||
/**
|
||||
* Default platform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
/*@ts2dart_Provider*/{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
||||
];
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[
|
||||
/*@ts2dart_Provider*/ {provide: APP_ID, useValue: 'a'},
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
Log,
|
||||
/*@ts2dart_Provider*/ {provide: NgZone, useFactory: createNgZone},
|
||||
/*@ts2dart_Provider*/ {provide: LocationStrategy, useClass: MockLocationStrategy},
|
||||
/*@ts2dart_Provider*/ {provide: AnimationBuilder, useClass: MockAnimationBuilder}
|
||||
];
|
||||
|
||||
/**
|
||||
* Default application providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
/*@ts2dart_const*/[BROWSER_APP_COMMON_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|
||||
|
Reference in New Issue
Block a user