fix(platform-browser): remove testing_e2e target (#10029)
The testing_e2e util does not belong in platform-browser and was never intended to be a public API. Move it out of that whole tree. BREAKING CHANGE: The following API was never intended to be public and is removed: ```js import {verifyNoBrowserErrors} from '@angular/platform-browser/testing_e2e'; ``` Consider using Protractor's console plugin: https://github.com/angular/protractor-console-plugin
This commit is contained in:
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
import * as webdriver from 'selenium-webdriver';
|
||||
|
||||
|
||||
declare var browser: any;
|
||||
declare var expect: any;
|
||||
|
||||
/**
|
||||
* @experimental This API will be moved to Protractor.
|
||||
*/
|
||||
export function verifyNoBrowserErrors() {
|
||||
// TODO(tbosch): Bug in ChromeDriver: Need to execute at least one command
|
||||
// so that the browser logs can be read out!
|
||||
browser.executeScript('1+1');
|
||||
browser.manage().logs().get('browser').then(function(browserLog: any) {
|
||||
var filteredLog = browserLog.filter(function(logEntry: any) {
|
||||
if (logEntry.level.value >= webdriver.logging.Level.INFO.value) {
|
||||
console.log('>> ' + logEntry.message);
|
||||
}
|
||||
return logEntry.level.value > webdriver.logging.Level.WARNING.value;
|
||||
});
|
||||
expect(filteredLog).toEqual([]);
|
||||
});
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
export {verifyNoBrowserErrors} from './e2e_util';
|
||||
|
||||
var benchpress = (global as any /** TODO #9100 */)['benchpress'];
|
||||
var bind = benchpress.bind;
|
||||
var Options = benchpress.Options;
|
||||
|
||||
export function runClickBenchmark(config: any /** TODO #9100 */) {
|
||||
browser.ignoreSynchronization = !config.waitForAngular2;
|
||||
var buttons =
|
||||
config.buttons.map(function(selector: any /** TODO #9100 */) { return $(selector); });
|
||||
config.work = function() {
|
||||
buttons.forEach(function(button: any /** TODO #9100 */) { button.click(); });
|
||||
};
|
||||
return runBenchmark(config);
|
||||
}
|
||||
|
||||
export function runBenchmark(config: any /** TODO #9100 */) {
|
||||
return getScaleFactor(browser.params.benchmark.scaling).then(function(scaleFactor) {
|
||||
var description = {};
|
||||
var urlParams: any[] /** TODO #9100 */ = [];
|
||||
if (config.params) {
|
||||
config.params.forEach(function(param: any /** TODO #9100 */) {
|
||||
var name = param.name;
|
||||
var value = applyScaleFactor(param.value, scaleFactor, param.scale);
|
||||
urlParams.push(name + '=' + value);
|
||||
(description as any /** TODO #9100 */)[name] = value;
|
||||
});
|
||||
}
|
||||
var url = encodeURI(config.url + '?' + urlParams.join('&'));
|
||||
return browser.get(url).then(function() {
|
||||
return (global as any /** TODO #9100 */)['benchpressRunner'].sample({
|
||||
id: config.id,
|
||||
execute: config.work,
|
||||
prepare: config.prepare,
|
||||
microMetrics: config.microMetrics,
|
||||
providers: [{provide: Options.SAMPLE_DESCRIPTION, useValue: description}]
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getScaleFactor(possibleScalings: any /** TODO #9100 */) {
|
||||
return browser.executeScript('return navigator.userAgent').then(function(userAgent: string) {
|
||||
var scaleFactor = 1;
|
||||
possibleScalings.forEach(function(entry: any /** TODO #9100 */) {
|
||||
if (userAgent.match(entry.userAgent)) {
|
||||
scaleFactor = entry.value;
|
||||
}
|
||||
});
|
||||
return scaleFactor;
|
||||
});
|
||||
}
|
||||
|
||||
function applyScaleFactor(
|
||||
value: any /** TODO #9100 */, scaleFactor: any /** TODO #9100 */,
|
||||
method: any /** TODO #9100 */) {
|
||||
if (method === 'log2') {
|
||||
return value + Math.log(scaleFactor) / Math.LN2;
|
||||
} else if (method === 'sqrt') {
|
||||
return value * Math.sqrt(scaleFactor);
|
||||
} else if (method === 'linear') {
|
||||
return value * scaleFactor;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user