2016-04-12 12:40:37 -04:00
|
|
|
import {
|
|
|
|
APP_ID,
|
|
|
|
NgZone,
|
|
|
|
Provider,
|
|
|
|
PLATFORM_COMMON_PROVIDERS,
|
|
|
|
PLATFORM_INITIALIZER
|
|
|
|
} from 'angular2/core';
|
2016-01-06 17:13:44 -05:00
|
|
|
import {DirectiveResolver, ViewResolver} from 'angular2/compiler';
|
2015-12-15 19:38:27 -05:00
|
|
|
import {BROWSER_APP_COMMON_PROVIDERS} from 'angular2/src/platform/browser_common';
|
|
|
|
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
|
|
|
|
|
|
|
|
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
|
|
|
import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
|
|
|
|
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
|
|
|
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
|
|
|
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
refactor(Location): out of router and into platform/common
closes https://github.com/angular/angular/issues/4943
BREAKING CHANGE:
`Location` and other related providers have been moved out of `router` and into `platform/common`. `BrowserPlatformLocation` is not meant to be used directly however advanced configurations may use it via the following import change.
Before:
```
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from 'angular2/router';
import {BrowserPlatformLocation} from 'angular2/src/router/location/browser_platform_location';
```
After:
```
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from 'angular2/platform/common';
import {BrowserPlatformLocation} from 'angular2/src/platform/browser/location/browser_platform_location';
```
Closes #7962
2016-04-08 03:31:20 -04:00
|
|
|
import {LocationStrategy} from 'angular2/platform/common';
|
2015-12-15 19:38:27 -05:00
|
|
|
import {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
|
|
|
|
|
2016-04-12 12:40:37 -04:00
|
|
|
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
2015-12-15 19:38:27 -05:00
|
|
|
import {XHR} from 'angular2/compiler';
|
|
|
|
|
2016-04-26 19:38:54 -04:00
|
|
|
import {
|
|
|
|
TestComponentBuilder,
|
|
|
|
ComponentFixtureAutoDetect,
|
|
|
|
ComponentFixtureNoNgZone
|
|
|
|
} from 'angular2/src/testing/test_component_builder';
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
import {BrowserDetection} from 'angular2/src/testing/utils';
|
|
|
|
|
|
|
|
import {ELEMENT_PROBE_PROVIDERS} from 'angular2/platform/common_dom';
|
|
|
|
|
2016-04-26 00:47:33 -04:00
|
|
|
import {IS_DART} from 'angular2/src/facade/lang';
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
import {Log} from 'angular2/src/testing/utils';
|
|
|
|
|
|
|
|
function initBrowserTests() {
|
|
|
|
BrowserDomAdapter.makeCurrent();
|
|
|
|
BrowserDetection.setup();
|
|
|
|
}
|
|
|
|
|
2016-04-26 19:38:54 -04:00
|
|
|
function createNgZone(): NgZone {
|
|
|
|
return IS_DART ? new MockNgZone() : new NgZone({enableLongStackTrace: true});
|
|
|
|
}
|
|
|
|
|
2015-12-15 19:38:27 -05:00
|
|
|
/**
|
2016-04-14 23:59:44 -04:00
|
|
|
* Default platform providers for testing without a compiler.
|
2015-12-15 19:38:27 -05:00
|
|
|
*/
|
|
|
|
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
2016-04-26 01:25:21 -04:00
|
|
|
/*@ts2dart_const*/[
|
2015-12-15 19:38:27 -05:00
|
|
|
PLATFORM_COMMON_PROVIDERS,
|
2016-04-26 00:58:48 -04:00
|
|
|
/*@ts2dart_Provider*/{provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true}
|
|
|
|
];
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
export const ADDITIONAL_TEST_BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
2016-04-26 00:47:33 -04:00
|
|
|
/*@ts2dart_const*/ [
|
2016-04-26 00:58:48 -04:00
|
|
|
/*@ts2dart_Provider*/{provide: APP_ID, useValue: 'a'},
|
2015-12-15 19:38:27 -05:00
|
|
|
ELEMENT_PROBE_PROVIDERS,
|
2016-04-26 00:58:48 -04:00
|
|
|
/*@ts2dart_Provider*/{provide: DirectiveResolver, useClass: MockDirectiveResolver},
|
|
|
|
/*@ts2dart_Provider*/{provide: ViewResolver, useClass: MockViewResolver},
|
2015-12-15 19:38:27 -05:00
|
|
|
Log,
|
|
|
|
TestComponentBuilder,
|
2016-04-26 00:58:48 -04:00
|
|
|
/*@ts2dart_Provider*/{provide: NgZone, useFactory: createNgZone},
|
|
|
|
/*@ts2dart_Provider*/{provide: LocationStrategy, useClass: MockLocationStrategy},
|
|
|
|
/*@ts2dart_Provider*/{provide: AnimationBuilder, useClass: MockAnimationBuilder},
|
|
|
|
];
|
2015-12-15 19:38:27 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default application providers for testing without a compiler.
|
|
|
|
*/
|
|
|
|
export const TEST_BROWSER_STATIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
2016-04-26 00:47:33 -04:00
|
|
|
/*@ts2dart_const*/ [
|
2016-04-12 12:40:37 -04:00
|
|
|
BROWSER_APP_COMMON_PROVIDERS,
|
2016-04-26 00:58:48 -04:00
|
|
|
/*@ts2dart_Provider*/{provide: XHR, useClass: XHRImpl},
|
2015-12-15 19:38:27 -05:00
|
|
|
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
2016-04-26 00:58:48 -04:00
|
|
|
];
|