2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 19:38:52 -04:00
|
|
|
import {COMPILER_PROVIDERS, DirectiveResolver, ViewResolver, XHR} from '@angular/compiler';
|
2016-06-24 20:35:01 -04:00
|
|
|
import {MockDirectiveResolver, MockViewResolver, OverridingTestComponentBuilder} from '@angular/compiler/testing';
|
2016-06-08 19:38:52 -04:00
|
|
|
import {APPLICATION_COMMON_PROVIDERS, APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER, RootRenderer} from '@angular/core';
|
2016-06-24 20:35:01 -04:00
|
|
|
import {TestComponentBuilder, TestComponentRenderer} from '@angular/core/testing';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-05-25 15:46:22 -04:00
|
|
|
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
2016-06-14 20:21:16 -04:00
|
|
|
import {DOMTestComponentRenderer} from '../platform_browser_dynamic_testing_private';
|
2016-06-14 15:34:31 -04:00
|
|
|
import {Parse5DomAdapter} from '../src/parse5_adapter';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
|
|
|
import {DOCUMENT, BROWSER_SANITIZATION_PROVIDERS, EventManager, EVENT_MANAGER_PLUGINS, ELEMENT_PROBE_PROVIDERS, DomEventsPlugin,} from '@angular/platform-browser';
|
2016-05-27 15:36:24 -04:00
|
|
|
import {getDOM, DomRootRenderer, DomRootRenderer_, DomSharedStylesHost, SharedStylesHost} from '../platform_browser_private';
|
2016-05-17 18:52:35 -04:00
|
|
|
import {LocationStrategy} from '@angular/common';
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
function initServerTests() {
|
|
|
|
Parse5DomAdapter.makeCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-14 23:59:44 -04:00
|
|
|
* Default platform providers for testing.
|
2015-12-15 19:38:27 -05:00
|
|
|
*/
|
2016-04-26 00:47:33 -04:00
|
|
|
export const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
2016-04-26 01:25:21 -04:00
|
|
|
/*@ts2dart_const*/[
|
2016-04-26 00:47:33 -04:00
|
|
|
PLATFORM_COMMON_PROVIDERS,
|
2016-06-08 19:38:52 -04:00
|
|
|
/*@ts2dart_Provider*/ {
|
|
|
|
provide: PLATFORM_INITIALIZER,
|
|
|
|
useValue: initServerTests,
|
|
|
|
multi: true
|
|
|
|
}
|
2016-04-26 00:58:48 -04:00
|
|
|
];
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
function appDoc() {
|
|
|
|
try {
|
2016-04-28 20:50:03 -04:00
|
|
|
return getDOM().defaultDoc();
|
2015-12-15 19:38:27 -05:00
|
|
|
} catch (e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
|
|
|
|
function createNgZone(): NgZone {
|
|
|
|
return new NgZone({enableLongStackTrace: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-15 19:38:27 -05:00
|
|
|
/**
|
|
|
|
* Default application providers for testing.
|
|
|
|
*/
|
|
|
|
export const TEST_SERVER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
2016-04-26 01:25:21 -04:00
|
|
|
/*@ts2dart_const*/[
|
2016-04-26 00:47:33 -04:00
|
|
|
// TODO(julie: when angular2/platform/server is available, use that instead of making our own
|
2015-12-15 19:38:27 -05:00
|
|
|
// list here.
|
2016-06-08 19:38:52 -04:00
|
|
|
APPLICATION_COMMON_PROVIDERS, COMPILER_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS,
|
2016-04-26 01:25:21 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: DOCUMENT, useFactory: appDoc},
|
|
|
|
/* @ts2dart_Provider */ {provide: DomRootRenderer, useClass: DomRootRenderer_},
|
|
|
|
/* @ts2dart_Provider */ {provide: RootRenderer, useExisting: DomRootRenderer},
|
2016-05-25 15:46:22 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: AnimationDriver, useClass: NoOpAnimationDriver},
|
2015-12-15 19:38:27 -05:00
|
|
|
EventManager,
|
2016-06-08 19:38:52 -04:00
|
|
|
/* @ts2dart_Provider */ {
|
|
|
|
provide: EVENT_MANAGER_PLUGINS,
|
|
|
|
useClass: DomEventsPlugin,
|
|
|
|
multi: true
|
|
|
|
},
|
2016-04-26 01:25:21 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: XHR, useClass: XHR},
|
|
|
|
/* @ts2dart_Provider */ {provide: APP_ID, useValue: 'a'},
|
|
|
|
/* @ts2dart_Provider */ {provide: SharedStylesHost, useExisting: DomSharedStylesHost},
|
2016-06-08 19:38:52 -04:00
|
|
|
DomSharedStylesHost, ELEMENT_PROBE_PROVIDERS,
|
2016-06-24 20:35:01 -04:00
|
|
|
{provide: TestComponentBuilder, useClass: OverridingTestComponentBuilder},
|
2016-04-26 01:25:21 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
2016-06-23 20:10:22 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: ViewResolver, useClass: MockViewResolver},
|
2016-04-28 20:50:03 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: TestComponentRenderer, useClass: DOMTestComponentRenderer},
|
2016-06-24 15:41:57 -04:00
|
|
|
/* @ts2dart_Provider */ {provide: NgZone, useFactory: createNgZone}
|
2016-04-26 00:58:48 -04:00
|
|
|
];
|