refactor(benchpress): export webdriver adapters in benchpress/benchpress
Also adds default bindings for protractor. Also removes sync web driver adapter for Dart as we don’t have tests for it yet.
This commit is contained in:
2
modules/benchpress/benchpress.dart
Normal file
2
modules/benchpress/benchpress.dart
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export './common.dart';
|
||||||
|
export './src/webdriver/async_webdriver_adapter.dart' show AsyncWebDriverAdapter;
|
2
modules/benchpress/benchpress.es6
Normal file
2
modules/benchpress/benchpress.es6
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './common';
|
||||||
|
export { SeleniumWebDriverAdapter } from './src/webdriver/selenium_webdriver_adapter';
|
@ -16,8 +16,8 @@ class AsyncWebDriverAdapter extends WebDriverAdapter {
|
|||||||
return _driver.execute(script, const[]);
|
return _driver.execute(script, const[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map capabilities() {
|
Future<Map> capabilities() {
|
||||||
return _driver.capabilities;
|
return new Future.value(_driver.capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Map>> logs(String type) {
|
Future<List<Map>> logs(String type) {
|
||||||
|
@ -8,6 +8,9 @@ import webdriver from 'selenium-webdriver';
|
|||||||
* Adapter for the selenium-webdriver.
|
* Adapter for the selenium-webdriver.
|
||||||
*/
|
*/
|
||||||
export class SeleniumWebDriverAdapter extends WebDriverAdapter {
|
export class SeleniumWebDriverAdapter extends WebDriverAdapter {
|
||||||
|
// TODO(tbosch): use static values when our transpiler supports them
|
||||||
|
static get PROTRACTOR_BINDINGS() { return _PROTRACTOR_BINDINGS; }
|
||||||
|
|
||||||
_driver:any;
|
_driver:any;
|
||||||
|
|
||||||
constructor(driver) {
|
constructor(driver) {
|
||||||
@ -59,3 +62,7 @@ function convertToLocalProcess(data) {
|
|||||||
}
|
}
|
||||||
return JSON.parse(serialized);
|
return JSON.parse(serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _PROTRACTOR_BINDINGS = [
|
||||||
|
bind(WebDriverAdapter).toFactory( () => new SeleniumWebDriverAdapter(global.browser), [])
|
||||||
|
];
|
@ -1,41 +0,0 @@
|
|||||||
library benchpress.src.webdriver.sync_webdriver_adapter_dart;
|
|
||||||
|
|
||||||
import 'package:angular2/src/facade/async.dart' show Future, PromiseWrapper;
|
|
||||||
import '../web_driver_adapter.dart' show WebDriverAdapter;
|
|
||||||
|
|
||||||
class SyncWebDriverAdapter extends WebDriverAdapter {
|
|
||||||
dynamic _driver;
|
|
||||||
SyncWebDriverAdapter(driver) {
|
|
||||||
this._driver = driver;
|
|
||||||
}
|
|
||||||
Future waitFor(Function callback) {
|
|
||||||
return this._convertToAsync(callback);
|
|
||||||
}
|
|
||||||
Future _convertToAsync(callback) {
|
|
||||||
try {
|
|
||||||
var result = callback();
|
|
||||||
if (result is Promise) {
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
return PromiseWrapper.resolve(result);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return PromiseWrapper.reject(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Future executeScript(String script) {
|
|
||||||
return this._convertToAsync(() {
|
|
||||||
return this._driver.execute(script);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Future capabilities() {
|
|
||||||
return this._convertToAsync(() {
|
|
||||||
return this._driver.capabilities;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Future logs(String type) {
|
|
||||||
return this._convertToAsync(() {
|
|
||||||
return this._driver.logs.get(script);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from '
|
|||||||
import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
||||||
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import { Metric, MultiMetric, bind, Injector } from 'benchpress/benchpress';
|
import { Metric, MultiMetric, bind, Injector } from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createMetric(ids) {
|
function createMetric(ids) {
|
||||||
|
@ -3,7 +3,7 @@ import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from '
|
|||||||
import { List, ListWrapper } from 'angular2/src/facade/collection';
|
import { List, ListWrapper } from 'angular2/src/facade/collection';
|
||||||
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import { Metric, PerflogMetric, WebDriverExtension, bind, Injector } from 'benchpress/benchpress';
|
import { Metric, PerflogMetric, WebDriverExtension, bind, Injector } from 'benchpress/common';
|
||||||
|
|
||||||
import { TraceEventFactory } from '../trace_event_factory';
|
import { TraceEventFactory } from '../trace_event_factory';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { List, ListWrapper } from 'angular2/src/facade/collection';
|
|||||||
import {
|
import {
|
||||||
SampleState, Reporter, bind, Injector,
|
SampleState, Reporter, bind, Injector,
|
||||||
ConsoleReporter, SampleDescription, MeasureValues
|
ConsoleReporter, SampleDescription, MeasureValues
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('console reporter', () => {
|
describe('console reporter', () => {
|
||||||
|
@ -4,7 +4,7 @@ import { List, ListWrapper, StringMap } from 'angular2/src/facade/collection';
|
|||||||
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
import { PromiseWrapper, Promise } from 'angular2/src/facade/async';
|
||||||
import { DateWrapper } from 'angular2/src/facade/lang';
|
import { DateWrapper } from 'angular2/src/facade/lang';
|
||||||
|
|
||||||
import { Reporter, MultiReporter, bind, Injector, MeasureValues } from 'benchpress/benchpress';
|
import { Reporter, MultiReporter, bind, Injector, MeasureValues } from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createReporters(ids) {
|
function createReporters(ids) {
|
||||||
|
@ -3,7 +3,7 @@ import {
|
|||||||
Runner, Sampler, SampleDescription,
|
Runner, Sampler, SampleDescription,
|
||||||
Validator, bind, Injector, Metric,
|
Validator, bind, Injector, Metric,
|
||||||
Options, WebDriverAdapter
|
Options, WebDriverAdapter
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
import { isBlank } from 'angular2/src/facade/lang';
|
import { isBlank } from 'angular2/src/facade/lang';
|
||||||
import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
|
import { Promise, PromiseWrapper } from 'angular2/src/facade/async';
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
Sampler, WebDriverAdapter, WebDriverExtension,
|
Sampler, WebDriverAdapter, WebDriverExtension,
|
||||||
Validator, Metric, Reporter, Browser,
|
Validator, Metric, Reporter, Browser,
|
||||||
bind, Injector, Options, MeasureValues
|
bind, Injector, Options, MeasureValues
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
var EMPTY_EXECUTE = () => {};
|
var EMPTY_EXECUTE = () => {};
|
||||||
|
@ -4,7 +4,7 @@ import { ListWrapper } from 'angular2/src/facade/collection';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Validator, RegressionSlopeValidator, Injector, bind, MeasureValues
|
Validator, RegressionSlopeValidator, Injector, bind, MeasureValues
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('regression slope validator', () => {
|
describe('regression slope validator', () => {
|
||||||
|
@ -4,7 +4,7 @@ import { ListWrapper } from 'angular2/src/facade/collection';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Validator, SizeValidator, Injector, bind, MeasureValues
|
Validator, SizeValidator, Injector, bind, MeasureValues
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
describe('size validator', () => {
|
describe('size validator', () => {
|
||||||
|
@ -4,7 +4,7 @@ import { StringMap, ListWrapper } from 'angular2/src/facade/collection';
|
|||||||
import { isPresent, StringWrapper } from 'angular2/src/facade/lang';
|
import { isPresent, StringWrapper } from 'angular2/src/facade/lang';
|
||||||
import { PromiseWrapper } from 'angular2/src/facade/async';
|
import { PromiseWrapper } from 'angular2/src/facade/async';
|
||||||
|
|
||||||
import { WebDriverExtension, bind, Injector, Options } from 'benchpress/benchpress';
|
import { WebDriverExtension, bind, Injector, Options } from 'benchpress/common';
|
||||||
|
|
||||||
export function main() {
|
export function main() {
|
||||||
function createExtension(ids, caps) {
|
function createExtension(ids, caps) {
|
||||||
|
@ -7,7 +7,7 @@ import { Json, isBlank } from 'angular2/src/facade/lang';
|
|||||||
import {
|
import {
|
||||||
WebDriverExtension, ChromeDriverExtension,
|
WebDriverExtension, ChromeDriverExtension,
|
||||||
WebDriverAdapter, Injector, bind
|
WebDriverAdapter, Injector, bind
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
import { TraceEventFactory } from '../trace_event_factory';
|
import { TraceEventFactory } from '../trace_event_factory';
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import { Json, isBlank, isPresent } from 'angular2/src/facade/lang';
|
|||||||
import {
|
import {
|
||||||
WebDriverExtension, IOsDriverExtension,
|
WebDriverExtension, IOsDriverExtension,
|
||||||
WebDriverAdapter, Injector, bind
|
WebDriverAdapter, Injector, bind
|
||||||
} from 'benchpress/benchpress';
|
} from 'benchpress/common';
|
||||||
|
|
||||||
import { TraceEventFactory } from '../trace_event_factory';
|
import { TraceEventFactory } from '../trace_event_factory';
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:io' show Platform;
|
import 'dart:io' show Platform;
|
||||||
import 'package:guinness/guinness.dart';
|
import 'package:guinness/guinness.dart';
|
||||||
import 'package:benchpress/benchpress.dart';
|
import 'package:benchpress/benchpress.dart';
|
||||||
import 'package:benchpress/src/webdriver/async_webdriver_adapter.dart';
|
|
||||||
import 'package:webdriver/webdriver.dart' show WebDriver, Capabilities, LogType, LogLevel, By;
|
import 'package:webdriver/webdriver.dart' show WebDriver, Capabilities, LogType, LogLevel, By;
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
@ -169,8 +169,6 @@ var config = exports.config = {
|
|||||||
exports.createBenchpressRunner = function(options) {
|
exports.createBenchpressRunner = function(options) {
|
||||||
var nodeUuid = require('node-uuid');
|
var nodeUuid = require('node-uuid');
|
||||||
var benchpress = require('./dist/js/cjs/benchpress/benchpress');
|
var benchpress = require('./dist/js/cjs/benchpress/benchpress');
|
||||||
var SeleniumWebDriverAdapter =
|
|
||||||
require('./dist/js/cjs/benchpress/src/webdriver/selenium_webdriver_adapter').SeleniumWebDriverAdapter;
|
|
||||||
|
|
||||||
// TODO(tbosch): add cloud reporter again (only when !options.test)
|
// TODO(tbosch): add cloud reporter again (only when !options.test)
|
||||||
// var cloudReporterConfig;
|
// var cloudReporterConfig;
|
||||||
@ -189,9 +187,7 @@ exports.createBenchpressRunner = function(options) {
|
|||||||
runId = process.env.GIT_SHA + ' ' + runId;
|
runId = process.env.GIT_SHA + ' ' + runId;
|
||||||
}
|
}
|
||||||
var bindings = [
|
var bindings = [
|
||||||
benchpress.bind(benchpress.WebDriverAdapter).toFactory(
|
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS,
|
||||||
function() { return new SeleniumWebDriverAdapter(global.browser); }, []
|
|
||||||
),
|
|
||||||
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
||||||
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
||||||
'lang': options.lang,
|
'lang': options.lang,
|
||||||
|
Reference in New Issue
Block a user