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-10 13:21:53 -04:00
|
|
|
import {LocationStrategy} from '@angular/common';
|
|
|
|
import {MockLocationStrategy} from '@angular/common/testing';
|
|
|
|
import {APP_ID, NgZone, PLATFORM_COMMON_PROVIDERS, PLATFORM_INITIALIZER} from '@angular/core';
|
|
|
|
import {Log} from '@angular/core/testing';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {AnimationDriver, NoOpAnimationDriver} from '../core_private';
|
|
|
|
import {BROWSER_APP_PROVIDERS} from '../src/browser';
|
|
|
|
import {BrowserDomAdapter} from '../src/browser/browser_adapter';
|
|
|
|
import {ELEMENT_PROBE_PROVIDERS} from '../src/dom/debug/ng_probe';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
import {BrowserDetection} from './browser_util';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
|
|
|
|
/**
|
2016-06-10 13:21:53 -04:00
|
|
|
* Default platform providers for testing without a compiler.
|
2016-04-28 20:50:03 -04:00
|
|
|
*/
|
2016-06-10 13:21:53 -04:00
|
|
|
const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = [
|
|
|
|
PLATFORM_COMMON_PROVIDERS,
|
|
|
|
{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
|
|
|
];
|
2016-05-13 16:22:29 -04:00
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
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: AnimationDriver, useClass: NoOpAnimationDriver}
|
2016-05-13 16:22:29 -04:00
|
|
|
];
|
|
|
|
|
2016-06-10 13:21:53 -04:00
|
|
|
|
|
|
|
function initBrowserTests() {
|
|
|
|
BrowserDomAdapter.makeCurrent();
|
|
|
|
BrowserDetection.setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
function createNgZone(): NgZone {
|
|
|
|
return new NgZone({enableLongStackTrace: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
/**
|
2016-06-10 13:21:53 -04:00
|
|
|
* Default platform providers for testing.
|
2016-04-28 20:50:03 -04:00
|
|
|
*/
|
2016-06-10 13:21:53 -04:00
|
|
|
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|
|
|
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default application providers for testing without a compiler.
|
|
|
|
*/
|
|
|
|
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
|
|
|
[BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_STATIC_PROVIDERS];
|