refactor: change provide(...) for {provide: ...}
- provide() is deprecated, - {} syntax is required by the offline compiler
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import {bind, provide} from '@angular/core/src/di';
|
||||
import {bind} from '@angular/core/src/di';
|
||||
import {Options} from './common';
|
||||
|
||||
export * from './common';
|
||||
@ -11,7 +11,7 @@ var fs = require('fs');
|
||||
// find another way...
|
||||
// Note: Can't do the `require` call in a facade as it can't be loaded into the browser
|
||||
// for our unit tests via karma.
|
||||
Options.DEFAULT_PROVIDERS.push(bind(Options.WRITE_FILE).toValue(writeFile));
|
||||
Options.DEFAULT_PROVIDERS.push({provide: Options.WRITE_FILE, useValue: writeFile});
|
||||
|
||||
function writeFile(filename, content): Promise<any> {
|
||||
return new Promise(function(resolve, reject) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
import {DateWrapper} from '@angular/facade';
|
||||
|
||||
export class Options {
|
||||
static get DEFAULT_PROVIDERS(): Provider[] { return _DEFAULT_PROVIDERS; }
|
||||
static get DEFAULT_PROVIDERS(): any[] { return _DEFAULT_PROVIDERS; }
|
||||
// TODO(tbosch): use static initializer when our transpiler supports it
|
||||
static get SAMPLE_ID() { return _SAMPLE_ID; }
|
||||
// TODO(tbosch): use static initializer when our transpiler supports it
|
||||
@ -49,14 +49,13 @@ var _REQUEST_COUNT = new OpaqueToken('Options.requestCount');
|
||||
var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');
|
||||
|
||||
var _DEFAULT_PROVIDERS = [
|
||||
bind(_DEFAULT_DESCRIPTION)
|
||||
.toValue({}),
|
||||
provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
|
||||
provide(_FORCE_GC, {useValue: false}),
|
||||
provide(_PREPARE, {useValue: false}),
|
||||
provide(_MICRO_METRICS, {useValue: {}}),
|
||||
provide(_NOW, {useValue: () => DateWrapper.now()}),
|
||||
provide(_RECEIVED_DATA, {useValue: false}),
|
||||
provide(_REQUEST_COUNT, {useValue: false}),
|
||||
provide(_CAPTURE_FRAMES, {useValue: false})
|
||||
{provide: _DEFAULT_DESCRIPTION, useValue: {}},
|
||||
{provide: _SAMPLE_DESCRIPTION, useValue: {}},
|
||||
{provide: _FORCE_GC, useValue: false},
|
||||
{provide: _PREPARE, useValue: false},
|
||||
{provide: _MICRO_METRICS, useValue: {}},
|
||||
{provide: _NOW, useValue: () => DateWrapper.now()},
|
||||
{provide: _RECEIVED_DATA, useValue: false},
|
||||
{provide: _REQUEST_COUNT, useValue: false},
|
||||
{provide: _CAPTURE_FRAMES, useValue: false}
|
||||
];
|
||||
|
@ -1,12 +1,11 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
|
||||
/**
|
||||
* A metric is measures values
|
||||
*/
|
||||
export abstract class Metric {
|
||||
static bindTo(delegateToken): Provider[] {
|
||||
return [bind(Metric).toFactory((delegate) => delegate, [delegateToken])];
|
||||
static bindTo(delegateToken): any[] {
|
||||
return [{provide: Metric, useFactory: (delegate) => delegate, deps: [delegateToken]}];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,16 +1,22 @@
|
||||
import {bind, provide, Binding, Provider, Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {StringMapWrapper} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
import {Metric} from '../metric';
|
||||
|
||||
export class MultiMetric extends Metric {
|
||||
static createBindings(childTokens: any[]): Provider[] {
|
||||
static createBindings(childTokens: any[]): any[] {
|
||||
return [
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(MultiMetric).toFactory(children => new MultiMetric(children), [_CHILDREN])
|
||||
{
|
||||
provide: _CHILDREN,
|
||||
useFactory:(injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
deps: [Injector]
|
||||
},
|
||||
{
|
||||
provide: MultiMetric,
|
||||
useFactory: children => new MultiMetric(children),
|
||||
deps: [_CHILDREN]
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
} from '@angular/facade';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
import {ListWrapper, StringMapWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
|
||||
import {Metric} from '../metric';
|
||||
@ -20,7 +20,7 @@ import {Options} from '../common_options';
|
||||
*/
|
||||
export class PerflogMetric extends Metric {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get SET_TIMEOUT(): OpaqueToken { return _SET_TIMEOUT; }
|
||||
|
||||
@ -364,19 +364,21 @@ var _MARK_NAME_FRAME_CAPUTRE = 'frameCapture';
|
||||
var _FRAME_TIME_SMOOTH_THRESHOLD = 17;
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(PerflogMetric)
|
||||
.toFactory(
|
||||
(driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
|
||||
requestCount) => new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc,
|
||||
captureFrames, receivedData, requestCount),
|
||||
[
|
||||
WebDriverExtension,
|
||||
_SET_TIMEOUT,
|
||||
Options.MICRO_METRICS,
|
||||
Options.FORCE_GC,
|
||||
Options.CAPTURE_FRAMES,
|
||||
Options.RECEIVED_DATA,
|
||||
Options.REQUEST_COUNT
|
||||
]),
|
||||
provide(_SET_TIMEOUT, {useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)})
|
||||
{
|
||||
provide: PerflogMetric,
|
||||
useFactory:
|
||||
(driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
|
||||
requestCount) => new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc,
|
||||
captureFrames, receivedData, requestCount),
|
||||
deps: [
|
||||
WebDriverExtension,
|
||||
_SET_TIMEOUT,
|
||||
Options.MICRO_METRICS,
|
||||
Options.FORCE_GC,
|
||||
Options.CAPTURE_FRAMES,
|
||||
Options.RECEIVED_DATA,
|
||||
Options.REQUEST_COUNT
|
||||
]
|
||||
},
|
||||
{provide: _SET_TIMEOUT, useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)}
|
||||
];
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
import {MeasureValues} from './measure_values';
|
||||
|
||||
@ -6,8 +5,8 @@ import {MeasureValues} from './measure_values';
|
||||
* A reporter reports measure values and the valid sample.
|
||||
*/
|
||||
export abstract class Reporter {
|
||||
static bindTo(delegateToken): Provider[] {
|
||||
return [bind(Reporter).toFactory((delegate) => delegate, [delegateToken])];
|
||||
static bindTo(delegateToken): any[] {
|
||||
return [{provide: Reporter, useFactory: (delegate) => delegate, deps: [delegateToken]}];
|
||||
}
|
||||
|
||||
reportMeasureValues(values: MeasureValues): Promise<any> { throw new BaseException('NYI'); }
|
||||
|
@ -2,7 +2,7 @@ import {print, isPresent, isBlank, NumberWrapper} from '@angular/facade';
|
||||
import {StringMapWrapper, ListWrapper} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
import {Math} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {Statistic} from '../statistic';
|
||||
import {Reporter} from '../reporter';
|
||||
@ -18,7 +18,7 @@ export class ConsoleReporter extends Reporter {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get COLUMN_WIDTH(): OpaqueToken { return _COLUMN_WIDTH; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
|
||||
static _lpad(value, columnWidth, fill = ' ') {
|
||||
@ -94,10 +94,12 @@ export class ConsoleReporter extends Reporter {
|
||||
var _PRINT = new OpaqueToken('ConsoleReporter.print');
|
||||
var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
|
||||
var _PROVIDERS = [
|
||||
bind(ConsoleReporter)
|
||||
.toFactory((columnWidth, sampleDescription, print) =>
|
||||
{
|
||||
provide: ConsoleReporter,
|
||||
useFactory: (columnWidth, sampleDescription, print) =>
|
||||
new ConsoleReporter(columnWidth, sampleDescription, print),
|
||||
[_COLUMN_WIDTH, SampleDescription, _PRINT]),
|
||||
provide(_COLUMN_WIDTH, {useValue: 18}),
|
||||
provide(_PRINT, {useValue: print})
|
||||
deps: [_COLUMN_WIDTH, SampleDescription, _PRINT]
|
||||
},
|
||||
{provide: _COLUMN_WIDTH, useValue: 18},
|
||||
{provide: _PRINT, useValue: print}
|
||||
];
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {DateWrapper, isPresent, isBlank, Json} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {Reporter} from '../reporter';
|
||||
import {SampleDescription} from '../sample_description';
|
||||
@ -15,7 +15,7 @@ export class JsonFileReporter extends Reporter {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PATH(): OpaqueToken { return _PATH; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
_writeFile: Function;
|
||||
_path: string;
|
||||
@ -48,9 +48,11 @@ export class JsonFileReporter extends Reporter {
|
||||
|
||||
var _PATH = new OpaqueToken('JsonFileReporter.path');
|
||||
var _PROVIDERS = [
|
||||
bind(JsonFileReporter)
|
||||
.toFactory((sampleDescription, path, writeFile, now) =>
|
||||
{
|
||||
provide: JsonFileReporter,
|
||||
useFactory: (sampleDescription, path, writeFile, now) =>
|
||||
new JsonFileReporter(sampleDescription, path, writeFile, now),
|
||||
[SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
|
||||
provide(_PATH, {useValue: '.'})
|
||||
deps: [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]
|
||||
},
|
||||
{provide: _PATH, useValue: '.'}
|
||||
];
|
||||
|
@ -1,16 +1,18 @@
|
||||
import {bind, provide, Provider, Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
import {MeasureValues} from '../measure_values';
|
||||
import {Reporter} from '../reporter';
|
||||
|
||||
export class MultiReporter extends Reporter {
|
||||
static createBindings(childTokens: any[]): Provider[] {
|
||||
static createBindings(childTokens: any[]): any[] {
|
||||
return [
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(MultiReporter).toFactory(children => new MultiReporter(children), [_CHILDREN])
|
||||
{
|
||||
provide: _CHILDREN,
|
||||
useFactory: (injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
deps: [Injector],
|
||||
},
|
||||
{provide: MultiReporter, useFactory: children => new MultiReporter(children), deps: [_CHILDREN]}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Injector, bind, provide, Provider, ReflectiveInjector} from '@angular/core';
|
||||
import {ReflectiveInjector} from '@angular/core';
|
||||
import {isPresent, isBlank} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
@ -25,8 +25,8 @@ import {Options} from './common_options';
|
||||
* It provides defaults, creates the injector and calls the sampler.
|
||||
*/
|
||||
export class Runner {
|
||||
private _defaultProviders: Provider[];
|
||||
constructor(defaultProviders: Provider[] = null) {
|
||||
private _defaultProviders: any[];
|
||||
constructor(defaultProviders: any[] = null) {
|
||||
if (isBlank(defaultProviders)) {
|
||||
defaultProviders = [];
|
||||
}
|
||||
@ -39,14 +39,14 @@ export class Runner {
|
||||
var sampleProviders = [
|
||||
_DEFAULT_PROVIDERS,
|
||||
this._defaultProviders,
|
||||
bind(Options.SAMPLE_ID).toValue(id),
|
||||
bind(Options.EXECUTE).toValue(execute)
|
||||
{provide: Options.SAMPLE_ID, useValue: id},
|
||||
{provide: Options.EXECUTE, useValue: execute}
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
sampleProviders.push(bind(Options.PREPARE).toValue(prepare));
|
||||
sampleProviders.push({provide: Options.PREPARE, useValue: prepare});
|
||||
}
|
||||
if (isPresent(microMetrics)) {
|
||||
sampleProviders.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
|
||||
sampleProviders.push({provide: Options.MICRO_METRICS, useValue: microMetrics});
|
||||
}
|
||||
if (isPresent(providers)) {
|
||||
sampleProviders.push(providers);
|
||||
@ -68,9 +68,9 @@ export class Runner {
|
||||
// injectors are handled better.
|
||||
var injector = ReflectiveInjector.resolveAndCreate([
|
||||
sampleProviders,
|
||||
bind(Options.CAPABILITIES).toValue(capabilities),
|
||||
bind(Options.USER_AGENT).toValue(userAgent),
|
||||
provide(WebDriverAdapter, {useValue: adapter})
|
||||
{provide: Options.CAPABILITIES, useValue: capabilities},
|
||||
{provide: Options.USER_AGENT, useValue: userAgent},
|
||||
{provide: WebDriverAdapter, useValue: adapter}
|
||||
]);
|
||||
|
||||
var sampler = injector.get(Sampler);
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {StringMapWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {Validator} from './validator';
|
||||
import {Metric} from './metric';
|
||||
import {Options} from './common_options';
|
||||
@ -9,7 +8,7 @@ import {Options} from './common_options';
|
||||
*/
|
||||
export class SampleDescription {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
description: {[key: string]: any};
|
||||
|
||||
constructor(public id: string, descriptions: Array<{[key: string]: any}>,
|
||||
@ -24,8 +23,9 @@ export class SampleDescription {
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(SampleDescription)
|
||||
.toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
||||
{
|
||||
provide: SampleDescription,
|
||||
useFactory: (metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
||||
new SampleDescription(id,
|
||||
[
|
||||
{'forceGc': forceGc, 'userAgent': userAgent},
|
||||
@ -34,13 +34,14 @@ var _PROVIDERS = [
|
||||
userDesc
|
||||
],
|
||||
metric.describe()),
|
||||
[
|
||||
Metric,
|
||||
Options.SAMPLE_ID,
|
||||
Options.FORCE_GC,
|
||||
Options.USER_AGENT,
|
||||
Validator,
|
||||
Options.DEFAULT_DESCRIPTION,
|
||||
Options.SAMPLE_DESCRIPTION
|
||||
])
|
||||
deps: [
|
||||
Metric,
|
||||
Options.SAMPLE_ID,
|
||||
Options.FORCE_GC,
|
||||
Options.USER_AGENT,
|
||||
Validator,
|
||||
Options.DEFAULT_DESCRIPTION,
|
||||
Options.SAMPLE_DESCRIPTION
|
||||
]
|
||||
}
|
||||
];
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {isPresent, isBlank, Date, DateWrapper} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {Metric} from './metric';
|
||||
import {Validator} from './validator';
|
||||
@ -20,7 +19,7 @@ import {MeasureValues} from './measure_values';
|
||||
*/
|
||||
export class Sampler {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
_driver: WebDriverAdapter;
|
||||
_metric: Metric;
|
||||
@ -95,26 +94,28 @@ export class SampleState {
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(Sampler)
|
||||
.toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
|
||||
driver: driver,
|
||||
reporter: reporter,
|
||||
validator: validator,
|
||||
metric: metric,
|
||||
// TODO(tbosch): DI right now does not support null/undefined objects
|
||||
// Mostly because the cache would have to be initialized with a
|
||||
// special null object, which is expensive.
|
||||
prepare: prepare !== false ? prepare : null,
|
||||
execute: execute,
|
||||
now: now
|
||||
}),
|
||||
[
|
||||
WebDriverAdapter,
|
||||
Metric,
|
||||
Reporter,
|
||||
Validator,
|
||||
Options.PREPARE,
|
||||
Options.EXECUTE,
|
||||
Options.NOW
|
||||
])
|
||||
{
|
||||
provide: Sampler,
|
||||
useFactory: (driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
|
||||
driver: driver,
|
||||
reporter: reporter,
|
||||
validator: validator,
|
||||
metric: metric,
|
||||
// TODO(tbosch): DI right now does not support null/undefined objects
|
||||
// Mostly because the cache would have to be initialized with a
|
||||
// special null object, which is expensive.
|
||||
prepare: prepare !== false ? prepare : null,
|
||||
execute: execute,
|
||||
now: now
|
||||
}),
|
||||
deps: [
|
||||
WebDriverAdapter,
|
||||
Metric,
|
||||
Reporter,
|
||||
Validator,
|
||||
Options.PREPARE,
|
||||
Options.EXECUTE,
|
||||
Options.NOW
|
||||
]
|
||||
}
|
||||
];
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
|
||||
import {MeasureValues} from './measure_values';
|
||||
@ -9,8 +8,8 @@ import {MeasureValues} from './measure_values';
|
||||
* in the correct way.
|
||||
*/
|
||||
export abstract class Validator {
|
||||
static bindTo(delegateToken): Provider[] {
|
||||
return [bind(Validator).toFactory((delegate) => delegate, [delegateToken])];
|
||||
static bindTo(delegateToken): any[] {
|
||||
return [{provide: Validator, useFactory: (delegate) => delegate, deps: [delegateToken]}];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {ListWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {Validator} from '../validator';
|
||||
import {Statistic} from '../statistic';
|
||||
@ -15,7 +15,7 @@ export class RegressionSlopeValidator extends Validator {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get METRIC(): OpaqueToken { return _METRIC; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
_sampleSize: number;
|
||||
_metric: string;
|
||||
@ -54,9 +54,11 @@ export class RegressionSlopeValidator extends Validator {
|
||||
var _SAMPLE_SIZE = new OpaqueToken('RegressionSlopeValidator.sampleSize');
|
||||
var _METRIC = new OpaqueToken('RegressionSlopeValidator.metric');
|
||||
var _PROVIDERS = [
|
||||
bind(RegressionSlopeValidator)
|
||||
.toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
|
||||
[_SAMPLE_SIZE, _METRIC]),
|
||||
provide(_SAMPLE_SIZE, {useValue: 10}),
|
||||
provide(_METRIC, {useValue: 'scriptTime'})
|
||||
{
|
||||
provide: RegressionSlopeValidator
|
||||
useFactory: (sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
|
||||
deps: [_SAMPLE_SIZE, _METRIC]
|
||||
},
|
||||
{provide: _SAMPLE_SIZE, useValue: 10},
|
||||
{provide: _METRIC, useValue: 'scriptTime'}
|
||||
];
|
||||
|
@ -1,5 +1,5 @@
|
||||
import {ListWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider, OpaqueToken} from '@angular/core/src/di';
|
||||
import {OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {Validator} from '../validator';
|
||||
import {MeasureValues} from '../measure_values';
|
||||
@ -9,7 +9,7 @@ import {MeasureValues} from '../measure_values';
|
||||
*/
|
||||
export class SizeValidator extends Validator {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get SAMPLE_SIZE() { return _SAMPLE_SIZE; }
|
||||
|
||||
@ -34,7 +34,10 @@ export class SizeValidator extends Validator {
|
||||
|
||||
var _SAMPLE_SIZE = new OpaqueToken('SizeValidator.sampleSize');
|
||||
var _PROVIDERS = [
|
||||
bind(SizeValidator)
|
||||
.toFactory((size) => new SizeValidator(size), [_SAMPLE_SIZE]),
|
||||
provide(_SAMPLE_SIZE, {useValue: 10})
|
||||
{
|
||||
provide: SizeValidator,
|
||||
useFactory: (size) => new SizeValidator(size),
|
||||
deps: [_SAMPLE_SIZE]
|
||||
},
|
||||
{provide: _SAMPLE_SIZE, useValue: 10}
|
||||
];
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
import {Map} from '@angular/facade';
|
||||
|
||||
@ -8,8 +7,8 @@ import {Map} from '@angular/facade';
|
||||
* Needs one implementation for every supported WebDriver client.
|
||||
*/
|
||||
export abstract class WebDriverAdapter {
|
||||
static bindTo(delegateToken): Provider[] {
|
||||
return [bind(WebDriverAdapter).toFactory((delegate) => delegate, [delegateToken])];
|
||||
static bindTo(delegateToken): any[] {
|
||||
return [{provide: WebDriverAdapter, useFactory: (delegate) => delegate, deps: [delegateToken]}];
|
||||
}
|
||||
|
||||
waitFor(callback: Function): Promise<any> { throw new BaseException('NYI'); }
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {bind, provide, Provider, Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
import {Injector, OpaqueToken} from '@angular/core/src/di';
|
||||
|
||||
import {isBlank, isPresent} from '@angular/facade';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
@ -11,26 +11,29 @@ import {Options} from './common_options';
|
||||
* Needs one implementation for every supported Browser.
|
||||
*/
|
||||
export abstract class WebDriverExtension {
|
||||
static bindTo(childTokens: any[]): Provider[] {
|
||||
static bindTo(childTokens: any[]): any[] {
|
||||
var res = [
|
||||
bind(_CHILDREN)
|
||||
.toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
[Injector]),
|
||||
bind(WebDriverExtension)
|
||||
.toFactory(
|
||||
(children: WebDriverExtension[], capabilities) => {
|
||||
var delegate;
|
||||
children.forEach(extension => {
|
||||
if (extension.supports(capabilities)) {
|
||||
delegate = extension;
|
||||
}
|
||||
});
|
||||
if (isBlank(delegate)) {
|
||||
throw new BaseException('Could not find a delegate for given capabilities!');
|
||||
}
|
||||
return delegate;
|
||||
},
|
||||
[_CHILDREN, Options.CAPABILITIES])
|
||||
{
|
||||
provide: _CHILDREN,
|
||||
useFactory: (injector: Injector) => childTokens.map(token => injector.get(token)),
|
||||
deps: [Injector]
|
||||
},
|
||||
{
|
||||
provide: WebDriverExtension,
|
||||
useFactory: (children:WebDriverExtension[], capabilities) => {
|
||||
var delegate;
|
||||
children.forEach(extension => {
|
||||
if (extension.supports(capabilities)) {
|
||||
delegate = extension;
|
||||
}
|
||||
});
|
||||
if (isBlank(delegate)) {
|
||||
throw new BaseException('Could not find a delegate for given capabilities!');
|
||||
}
|
||||
return delegate;
|
||||
},
|
||||
deps: [_CHILDREN, Options.CAPABILITIES]
|
||||
}
|
||||
];
|
||||
return res;
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {ListWrapper, StringMapWrapper} from '@angular/facade';
|
||||
import {
|
||||
Json,
|
||||
@ -23,7 +22,7 @@ import {Options} from '../common_options';
|
||||
*/
|
||||
export class ChromeDriverExtension extends WebDriverExtension {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
private _majorChromeVersion: number;
|
||||
|
||||
@ -247,7 +246,9 @@ function normalizeEvent(chromeEvent: {[key: string]: any},
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(ChromeDriverExtension)
|
||||
.toFactory((driver, userAgent) => new ChromeDriverExtension(driver, userAgent),
|
||||
[WebDriverAdapter, Options.USER_AGENT])
|
||||
{
|
||||
provide: ChromeDriverExtension,
|
||||
useFactory: (driver, userAgent) => new ChromeDriverExtension(driver, userAgent),
|
||||
deps: [WebDriverAdapter, Options.USER_AGENT]
|
||||
}
|
||||
];
|
||||
|
@ -1,10 +1,9 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {isPresent, StringWrapper} from '@angular/facade';
|
||||
import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
|
||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||
|
||||
export class FirefoxDriverExtension extends WebDriverExtension {
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
private _profilerStarted: boolean;
|
||||
|
||||
@ -43,6 +42,9 @@ export class FirefoxDriverExtension extends WebDriverExtension {
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(FirefoxDriverExtension)
|
||||
.toFactory((driver) => new FirefoxDriverExtension(driver), [WebDriverAdapter])
|
||||
{
|
||||
provide: FirefoxDriverExtension,
|
||||
useFactory: (driver) => new FirefoxDriverExtension(driver),
|
||||
deps: [WebDriverAdapter]
|
||||
}
|
||||
];
|
||||
|
@ -1,4 +1,3 @@
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {Json, isPresent, isBlank, RegExpWrapper, StringWrapper} from '@angular/facade';
|
||||
import {BaseException, WrappedException} from '@angular/facade';
|
||||
|
||||
@ -7,7 +6,7 @@ import {WebDriverAdapter} from '../web_driver_adapter';
|
||||
|
||||
export class IOsDriverExtension extends WebDriverExtension {
|
||||
// TODO(tbosch): use static values when our transpiler supports them
|
||||
static get PROVIDERS(): Provider[] { return _PROVIDERS; }
|
||||
static get PROVIDERS(): any[] { return _PROVIDERS; }
|
||||
|
||||
constructor(private _driver: WebDriverAdapter) { super(); }
|
||||
|
||||
@ -121,6 +120,5 @@ function createMarkEndEvent(name, time) {
|
||||
}
|
||||
|
||||
var _PROVIDERS = [
|
||||
bind(IOsDriverExtension)
|
||||
.toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])
|
||||
{provide: IOsDriverExtension, useFactory: (driver) => new IOsDriverExtension(driver), deps: [WebDriverAdapter]}
|
||||
];
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
import {bind, provide, Provider} from '@angular/core/src/di';
|
||||
import {WebDriverAdapter} from '../web_driver_adapter';
|
||||
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
@ -8,7 +7,7 @@ import * as webdriver from 'selenium-webdriver';
|
||||
* Adapter for the selenium-webdriver.
|
||||
*/
|
||||
export class SeleniumWebDriverAdapter extends WebDriverAdapter {
|
||||
static get PROTRACTOR_BINDINGS(): Provider[] { return _PROTRACTOR_BINDINGS; }
|
||||
static get PROTRACTOR_BINDINGS(): any[] { return _PROTRACTOR_BINDINGS; }
|
||||
|
||||
constructor(private _driver: any) { super(); }
|
||||
|
||||
@ -57,6 +56,5 @@ function convertToLocalProcess(data): Object {
|
||||
}
|
||||
|
||||
var _PROTRACTOR_BINDINGS = [
|
||||
bind(WebDriverAdapter)
|
||||
.toFactory(() => new SeleniumWebDriverAdapter((<any>global).browser), [])
|
||||
{provide: WebDriverAdapter, useFactory: () => new SeleniumWebDriverAdapter((<any>global).browser), deps: []}
|
||||
];
|
||||
|
@ -10,12 +10,12 @@ import {
|
||||
xit,
|
||||
} from '@angular/core/testing';
|
||||
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
|
||||
import {Metric, MultiMetric, bind, provide, ReflectiveInjector} from 'benchpress/common';
|
||||
import {Metric, MultiMetric, ReflectiveInjector} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
function createMetric(ids: any[]) {
|
||||
var m = ReflectiveInjector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockMetric(id)})),
|
||||
ids.map(id => {return {provide: id, useValue: new MockMetric(id)}}),
|
||||
MultiMetric.createBindings(ids)
|
||||
])
|
||||
.get(MultiMetric);
|
||||
|
@ -20,8 +20,6 @@ import {
|
||||
PerflogMetric,
|
||||
WebDriverExtension,
|
||||
PerfLogFeatures,
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
Options
|
||||
} from 'benchpress/common';
|
||||
@ -51,26 +49,30 @@ export function main() {
|
||||
var providers = [
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
PerflogMetric.PROVIDERS,
|
||||
bind(Options.MICRO_METRICS).toValue(microMetrics),
|
||||
bind(PerflogMetric.SET_TIMEOUT)
|
||||
.toValue((fn, millis) => {
|
||||
commandLog.push(['setTimeout', millis]);
|
||||
fn();
|
||||
}),
|
||||
bind(WebDriverExtension)
|
||||
.toValue(new MockDriverExtension(perfLogs, commandLog, perfLogFeatures))
|
||||
{provide: Options.MICRO_METRICS, useValue: microMetrics},
|
||||
{
|
||||
provide: PerflogMetric.SET_TIMEOUT,
|
||||
useValue: (fn, millis) => {
|
||||
commandLog.push(['setTimeout', millis]);
|
||||
fn();
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: WebDriverExtension,
|
||||
useValue: new MockDriverExtension(perfLogs, commandLog, perfLogFeatures)
|
||||
}
|
||||
];
|
||||
if (isPresent(forceGc)) {
|
||||
providers.push(bind(Options.FORCE_GC).toValue(forceGc));
|
||||
providers.push({provide: Options.FORCE_GC, useValue(forceGc)};
|
||||
}
|
||||
if (isPresent(captureFrames)) {
|
||||
providers.push(bind(Options.CAPTURE_FRAMES).toValue(captureFrames));
|
||||
providers.push({provide: Options.CAPTURE_FRAMES, useValue: captureFrames});
|
||||
}
|
||||
if (isPresent(receivedData)) {
|
||||
providers.push(bind(Options.RECEIVED_DATA).toValue(receivedData));
|
||||
providers.push({provide: Options.RECEIVED_DATA, useValue: receivedData});
|
||||
}
|
||||
if (isPresent(requestCount)) {
|
||||
providers.push(bind(Options.REQUEST_COUNT).toValue(requestCount));
|
||||
providers.push({provide: Options.REQUEST_COUNT, useValue: requestCount});
|
||||
}
|
||||
return ReflectiveInjector.resolveAndCreate(providers).get(PerflogMetric);
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ import {isBlank, isPresent, Date, DateWrapper} from '@angular/facade';
|
||||
import {
|
||||
SampleState,
|
||||
Reporter,
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
ConsoleReporter,
|
||||
SampleDescription,
|
||||
@ -38,12 +36,11 @@ export function main() {
|
||||
}
|
||||
var bindings = [
|
||||
ConsoleReporter.PROVIDERS,
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(ConsoleReporter.PRINT).toValue((line) => log.push(line))
|
||||
{provide: SampleDescription, useValue: new SampleDescription(sampleId, descriptions, metrics)},
|
||||
{provide: ConsoleReporter.PRINT, useValue: (line) => log.push(line)}
|
||||
];
|
||||
if (isPresent(columnWidth)) {
|
||||
bindings.push(bind(ConsoleReporter.COLUMN_WIDTH).toValue(columnWidth));
|
||||
bindings.push({provide: ConsoleReporter.COLUMN_WIDTH, useValue(columnWidth)};
|
||||
}
|
||||
reporter = ReflectiveInjector.resolveAndCreate(bindings).get(ConsoleReporter);
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ import {DateWrapper, Json, RegExpWrapper, isPresent} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
import {
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
SampleDescription,
|
||||
MeasureValues,
|
||||
@ -33,15 +31,16 @@ export function main() {
|
||||
function createReporter({sampleId, descriptions, metrics, path}) {
|
||||
var bindings = [
|
||||
JsonFileReporter.PROVIDERS,
|
||||
provide(SampleDescription,
|
||||
{useValue: new SampleDescription(sampleId, descriptions, metrics)}),
|
||||
bind(JsonFileReporter.PATH).toValue(path),
|
||||
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(1234)),
|
||||
bind(Options.WRITE_FILE)
|
||||
.toValue((filename, content) => {
|
||||
loggedFile = {'filename': filename, 'content': content};
|
||||
return PromiseWrapper.resolve(null);
|
||||
})
|
||||
{provide: SampleDescription, useValue: new SampleDescription(sampleId, descriptions, metrics)},
|
||||
{provide: JsonFileReporter.PATH, useValue(path)},
|
||||
{provide: Options.NOW, useValue: () => DateWrapper.fromMillis(1234)},
|
||||
{
|
||||
provide: Options.WRITE_FILE,
|
||||
useValue: (filename, content) => {
|
||||
loggedFile = {'filename': filename, 'content': content};
|
||||
return PromiseWrapper.resolve(null);
|
||||
}
|
||||
}
|
||||
];
|
||||
return ReflectiveInjector.resolveAndCreate(bindings).get(JsonFileReporter);
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ import {DateWrapper} from '@angular/facade';
|
||||
import {
|
||||
Reporter,
|
||||
MultiReporter,
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
@ -26,7 +24,7 @@ import {
|
||||
export function main() {
|
||||
function createReporters(ids: any[]) {
|
||||
var r = ReflectiveInjector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockReporter(id)})),
|
||||
ids.map(id => { return {provide: id, useValue: new MockReporter(id)}}),
|
||||
MultiReporter.createBindings(ids)
|
||||
])
|
||||
.get(MultiReporter);
|
||||
|
@ -15,8 +15,6 @@ import {
|
||||
Sampler,
|
||||
SampleDescription,
|
||||
Validator,
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
Injector,
|
||||
Metric,
|
||||
@ -38,15 +36,17 @@ export function main() {
|
||||
}
|
||||
runner = new Runner([
|
||||
defaultBindings,
|
||||
bind(Sampler).toFactory(
|
||||
(_injector) => {
|
||||
injector = _injector;
|
||||
return new MockSampler();
|
||||
},
|
||||
[Injector]),
|
||||
bind(Metric).toFactory(() => new MockMetric(), []),
|
||||
bind(Validator).toFactory(() => new MockValidator(), []),
|
||||
bind(WebDriverAdapter).toFactory(() => new MockWebDriverAdapter(), [])
|
||||
{
|
||||
provide: Sampler,
|
||||
useFactory: (_injector) => {
|
||||
injector = _injector;
|
||||
return new MockSampler();
|
||||
},
|
||||
deps: [Injector]
|
||||
},
|
||||
{ provide: Metric, useFactory: () => new MockMetric(), deps: []},
|
||||
{ provide: Validator, useFactory: () => new MockValidator(), deps: []},
|
||||
{ provide: WebDriverAdapter, useFactory: () => new MockWebDriverAdapter(), deps: []}
|
||||
]);
|
||||
return runner;
|
||||
}
|
||||
@ -62,8 +62,8 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should merge SampleDescription.description', inject([AsyncTestCompleter], (async) => {
|
||||
createRunner([bind(Options.DEFAULT_DESCRIPTION).toValue({'a': 1})])
|
||||
.sample({id: 'someId', providers: [bind(Options.SAMPLE_DESCRIPTION).toValue({'b': 2})]})
|
||||
createRunner([{provide: Options.DEFAULT_DESCRIPTION, useValue: {'a': 1}}])
|
||||
.sample({id: 'someId', providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: {'b': 2}}]})
|
||||
.then((_) => injector.get(SampleDescription))
|
||||
.then((desc) => {
|
||||
expect(desc.description)
|
||||
@ -115,16 +115,10 @@ export function main() {
|
||||
}));
|
||||
|
||||
it('should overwrite bindings per sample call', inject([AsyncTestCompleter], (async) => {
|
||||
createRunner([
|
||||
bind(Options.DEFAULT_DESCRIPTION)
|
||||
.toValue({'a': 1}),
|
||||
])
|
||||
createRunner([{provide: Options.DEFAULT_DESCRIPTION, useValue: {'a': 1}}])
|
||||
.sample({
|
||||
id: 'someId',
|
||||
providers: [
|
||||
bind(Options.DEFAULT_DESCRIPTION)
|
||||
.toValue({'a': 2}),
|
||||
]
|
||||
providers: [{provide: Options.DEFAULT_DESCRIPTION, useValue: {'a': 2}}]
|
||||
})
|
||||
.then((_) => injector.get(SampleDescription))
|
||||
.then((desc) => {
|
||||
|
@ -20,8 +20,6 @@ import {
|
||||
Validator,
|
||||
Metric,
|
||||
Reporter,
|
||||
bind,
|
||||
provide,
|
||||
ReflectiveInjector,
|
||||
Options,
|
||||
MeasureValues
|
||||
@ -54,15 +52,15 @@ export function main() {
|
||||
var providers = [
|
||||
Options.DEFAULT_PROVIDERS,
|
||||
Sampler.PROVIDERS,
|
||||
provide(Metric, {useValue: metric}),
|
||||
provide(Reporter, {useValue: reporter}),
|
||||
provide(WebDriverAdapter, {useValue: driver}),
|
||||
bind(Options.EXECUTE).toValue(execute),
|
||||
provide(Validator, {useValue: validator}),
|
||||
bind(Options.NOW).toValue(() => DateWrapper.fromMillis(time++))
|
||||
{provide: Metric, useValue: metric},
|
||||
{provide: Reporter, useValue: reporter},
|
||||
{provide: WebDriverAdapter, useValue: driver},
|
||||
{provide: Options.EXECUTE, useValue: execute},
|
||||
{provide: Validator, useValue: validator},
|
||||
{provide: Options.NOW, useValue: () => DateWrapper.fromMillis(time++)}
|
||||
];
|
||||
if (isPresent(prepare)) {
|
||||
providers.push(bind(Options.PREPARE).toValue(prepare));
|
||||
providers.push({provide: Options.PREPARE, useValue: prepare});
|
||||
}
|
||||
|
||||
sampler = ReflectiveInjector.resolveAndCreate(providers).get(Sampler);
|
||||
|
@ -12,11 +12,8 @@ import {Date, DateWrapper} from '@angular/facade';
|
||||
import {ListWrapper} from '@angular/facade';
|
||||
|
||||
import {
|
||||
Validator,
|
||||
RegressionSlopeValidator,
|
||||
ReflectiveInjector,
|
||||
bind,
|
||||
provide,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
|
||||
@ -27,8 +24,8 @@ export function main() {
|
||||
function createValidator({size, metric}) {
|
||||
validator = ReflectiveInjector.resolveAndCreate([
|
||||
RegressionSlopeValidator.PROVIDERS,
|
||||
provide(RegressionSlopeValidator.METRIC).toValue(metric),
|
||||
provide(RegressionSlopeValidator.SAMPLE_SIZE).toValue(size)
|
||||
{provide: RegressionSlopeValidator.METRIC, useValue(metric)},
|
||||
{provide: RegressionSlopeValidator.SAMPLE_SIZE, useValue(size)}
|
||||
])
|
||||
.get(RegressionSlopeValidator);
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ import {
|
||||
Validator,
|
||||
SizeValidator,
|
||||
ReflectiveInjector,
|
||||
bind,
|
||||
provide,
|
||||
MeasureValues
|
||||
} from 'benchpress/common';
|
||||
|
||||
@ -27,7 +25,7 @@ export function main() {
|
||||
function createValidator(size) {
|
||||
validator = ReflectiveInjector.resolveAndCreate([
|
||||
SizeValidator.PROVIDERS,
|
||||
provide(SizeValidator.SAMPLE_SIZE).toValue(size)
|
||||
{provide: SizeValidator.SAMPLE_SIZE, useValue: size}
|
||||
])
|
||||
.get(SizeValidator);
|
||||
}
|
||||
|
@ -14,14 +14,14 @@ import {
|
||||
import {isPresent, StringWrapper} from '@angular/facade';
|
||||
import {PromiseWrapper} from '@angular/facade';
|
||||
|
||||
import {WebDriverExtension, bind, provide, ReflectiveInjector, Options} from 'benchpress/common';
|
||||
import {WebDriverExtension, ReflectiveInjector, Options} from 'benchpress/common';
|
||||
|
||||
export function main() {
|
||||
function createExtension(ids: any[], caps) {
|
||||
return PromiseWrapper.wrap(() => {
|
||||
return ReflectiveInjector.resolveAndCreate([
|
||||
ids.map(id => provide(id, {useValue: new MockExtension(id)})),
|
||||
bind(Options.CAPABILITIES).toValue(caps),
|
||||
ids.map((id) => { return {provide: id, useValue: new MockExtension(id)}}),
|
||||
{provide: Options.CAPABILITIES, useValue: caps},
|
||||
WebDriverExtension.bindTo(ids)
|
||||
])
|
||||
.get(WebDriverExtension);
|
||||
|
@ -19,8 +19,6 @@ import {
|
||||
ChromeDriverExtension,
|
||||
WebDriverAdapter,
|
||||
ReflectiveInjector,
|
||||
bind,
|
||||
provide,
|
||||
Options
|
||||
} from 'benchpress/common';
|
||||
|
||||
@ -60,9 +58,8 @@ export function main() {
|
||||
extension =
|
||||
ReflectiveInjector.resolveAndCreate([
|
||||
ChromeDriverExtension.PROVIDERS,
|
||||
provide(WebDriverAdapter)
|
||||
.toValue(new MockDriverAdapter(log, perfRecords, messageMethod)),
|
||||
provide(Options.USER_AGENT).toValue(userAgent)
|
||||
{provide: WebDriverAdapter, useValue: new MockDriverAdapter(log, perfRecords, messageMethod)},
|
||||
{provide: Options.USER_AGENT, useValue(userAgent)}
|
||||
])
|
||||
.get(ChromeDriverExtension);
|
||||
return extension;
|
||||
|
@ -19,8 +19,6 @@ import {
|
||||
IOsDriverExtension,
|
||||
WebDriverAdapter,
|
||||
ReflectiveInjector,
|
||||
bind,
|
||||
provide
|
||||
} from 'benchpress/common';
|
||||
|
||||
import {TraceEventFactory} from '../trace_event_factory';
|
||||
@ -39,8 +37,7 @@ export function main() {
|
||||
log = [];
|
||||
extension = ReflectiveInjector.resolveAndCreate([
|
||||
IOsDriverExtension.PROVIDERS,
|
||||
provide(WebDriverAdapter,
|
||||
{useValue: new MockDriverAdapter(log, perfRecords)})
|
||||
{provide: WebDriverAdapter, useValue: new MockDriverAdapter(log, perfRecords)}
|
||||
])
|
||||
.get(IOsDriverExtension);
|
||||
return extension;
|
||||
|
Reference in New Issue
Block a user