Skip to content

Commit 3b40052

Browse files
committed
feat(build): enforce mobile layout during e2e tests
This is important as we run our benchmarks on mobile devices as web driver tests fails if buttons are not visible / overlaid by other content.
1 parent 7e6f536 commit 3b40052

File tree

8 files changed

+53
-41
lines changed

8 files changed

+53
-41
lines changed

modules/benchmarks/e2e_test/naive_infinite_scroll_perf.es6

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('ng2 naive infinite scroll benchmark', function () {
1313
url: URL,
1414
id: 'ng2.naive_infinite_scroll',
1515
work: function() {
16-
element(by.deepCss('#reset-btn')).click();
17-
element(by.deepCss('#run-btn')).click();
16+
$('#reset-btn').click();
17+
$('#run-btn').click();
1818
browser.wait(() => {
1919
return $('#done').getText().then(
2020
function() { return true; },

modules/benchmarks/e2e_test/naive_infinite_scroll_spec.es6

+2-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ describe('ng2 naive infinite scroll benchmark', function () {
5353
});
5454
})
5555

56-
browser.executeScript(
57-
'document.querySelector("scroll-app /deep/ #reset-btn").click()');
58-
browser.executeScript(
59-
'document.querySelector("scroll-app /deep/ #run-btn").click()');
56+
$("#reset-btn").click();
57+
$("#run-btn").click();
6058
browser.wait(() => {
6159
return $('#done').getText().then(
6260
function() { return true; },

modules/benchmarks/src/naive_infinite_scroll/app.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ export class App {
2323
for (var i = 0; i < appSize; i++) {
2424
ListWrapper.push(this.scrollAreas, i);
2525
}
26-
// TODO(tbosch): change to bindAction when it works in pub serve
27-
DOM.on(DOM.query('scroll-app /deep/ #run-btn'), 'click', (_) => {
26+
bindAction('#run-btn', () => {
2827
this.runBenchmark();
2928
});
30-
DOM.on(DOM.query('scroll-app /deep/ #reset-btn'), 'click', (_) => {
29+
bindAction('#reset-btn', () => {
3130
this._getScrollDiv().scrollTop = 0;
3231
var existingMarker = this._locateFinishedMarker();
3332
if (isPresent(existingMarker)) {
@@ -90,10 +89,6 @@ export function setupReflectorForApp() {
9089
<div>
9190
<div style="display: flex">
9291
<scroll-area id="testArea"></scroll-area>
93-
<div style="padding-left: 20px">
94-
<button id="run-btn">Run</button>
95-
<button id="reset-btn">Reset</button>
96-
</div>
9792
</div>
9893
<div template="if scrollAreas.length > 0">
9994
<p>Following tables are only here to add weight to the UI:</p>

modules/benchmarks/src/naive_infinite_scroll/index.html

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
Iteration count: <input type="text" name="iterationCount" value="1"></input><br>
1010
Scroll increment: <input type="text" name="scrollIncrement" value="1"></input><br>
1111
</form>
12+
<div>
13+
<button id="run-btn">Run</button>
14+
<button id="reset-btn">Reset</button>
15+
</div>
1216
<scroll-app></scroll-app>
1317

1418
$SCRIPTS$

modules/benchmarks_external/e2e_test/naive_infinite_scroll_perf.es6

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('ng-dart1.x naive infinite scroll benchmark', function () {
1313
url: URL,
1414
id: 'ng1-dart1.x.naive_infinite_scroll',
1515
work: function() {
16-
element(by.deepCss('#reset-btn')).click();
17-
element(by.deepCss('#run-btn')).click();
16+
$('#reset-btn').click();
17+
$('#run-btn').click();
1818
var s = 1000;
1919
if (appSize > 4) {
2020
s = s + appSize * 100;

modules/benchmarks_external/src/naive_infinite_scroll/app.dart

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ import 'package:angular2/src/test_lib/benchmark_util.dart';
1111
<div>
1212
<div style="display: flex">
1313
<scroll-area scroll-top="scrollTop"></scroll-area>
14-
<div style="padding-left: 20px">
15-
<button id='run-btn'>Run</button>
16-
<button id='reset-btn'>Reset</button>
17-
</div>
1814
</div>
1915
<div ng-if="scrollAreas.length > 0">
2016
<p>Following tables are only here to add weight to the UI:</p>
@@ -39,10 +35,10 @@ class App implements ShadowRootAware {
3935

4036
@override
4137
void onShadowRoot(ShadowRoot shadowRoot) {
42-
bindAction('scroll-app /deep/ #run-btn', () {
38+
bindAction('#run-btn', () {
4339
runBenchmark();
4440
});
45-
bindAction('scroll-app /deep/ #reset-btn', () {
41+
bindAction('#reset-btn', () {
4642
scrollTop = 0;
4743
});
4844
}

modules/benchmarks_external/src/naive_infinite_scroll/index.html

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
Iteration count: <input type="text" name="iterationCount" value="1"></input><br>
1010
Scroll increment: <input type="text" name="scrollIncrement" value="1"></input><br>
1111
</form>
12+
<div>
13+
<button id="run-btn">Run</button>
14+
<button id="reset-btn">Reset</button>
15+
</div>
1216
<scroll-app></scroll-app>
1317

1418
$SCRIPTS$

protractor-shared.js

+35-20
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,52 @@ var argv = require('yargs')
3333

3434
var browsers = argv['browsers'].split(',');
3535

36+
var CHROME_OPTIONS = {
37+
'args': ['--js-flags=--expose-gc'],
38+
'perfLoggingPrefs': {
39+
'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
40+
}
41+
};
42+
43+
var CHROME_MOBILE_EMULATION = {
44+
// Can't use 'deviceName':'Google Nexus 7 2'
45+
// as this would yield wrong orientation,
46+
// so we specify facts explicitly
47+
'deviceMetrics': {
48+
'width': 600,
49+
'height': 960,
50+
'pixelRatio': 2
51+
}
52+
};
53+
3654
var BROWSER_CAPS = {
3755
Dartium: {
3856
name: 'Dartium',
3957
browserName: 'chrome',
40-
chromeOptions: {
41-
'binary': process.env.DARTIUM,
42-
'args': ['--js-flags=--expose-gc'],
43-
'perfLoggingPrefs': {
44-
'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
45-
}
46-
},
58+
chromeOptions: mergeInto(CHROME_OPTIONS, {
59+
'mobileEmulation': CHROME_MOBILE_EMULATION,
60+
'binary': process.env.DARTIUM
61+
}),
4762
loggingPrefs: {
4863
performance: 'ALL',
4964
browser: 'ALL'
5065
}
5166
},
5267
ChromeDesktop: {
5368
browserName: 'chrome',
54-
chromeOptions: {
55-
'args': ['--js-flags=--expose-gc'],
56-
'perfLoggingPrefs': {
57-
'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
58-
}
59-
},
69+
chromeOptions: mergeInto(CHROME_OPTIONS, {
70+
'mobileEmulation': CHROME_MOBILE_EMULATION
71+
}),
6072
loggingPrefs: {
6173
performance: 'ALL',
6274
browser: 'ALL'
6375
}
6476
},
6577
ChromeAndroid: {
6678
browserName: 'chrome',
67-
chromeOptions: {
68-
androidPackage: 'com.android.chrome',
69-
'args': ['--js-flags=--expose-gc'],
70-
'perfLoggingPrefs': {
71-
'traceCategories': 'blink.console,disabled-by-default-devtools.timeline'
72-
}
73-
},
79+
chromeOptions: mergeInto(CHROME_OPTIONS, {
80+
'androidPackage': 'com.android.chrome',
81+
}),
7482
loggingPrefs: {
7583
performance: 'ALL',
7684
browser: 'ALL'
@@ -201,3 +209,10 @@ exports.createBenchpressRunner = function(options) {
201209

202210
global.benchpressRunner = new benchpress.Runner(bindings);
203211
}
212+
213+
function mergeInto(src, target) {
214+
for (var prop in src) {
215+
target[prop] = src[prop];
216+
}
217+
return target;
218+
}

0 commit comments

Comments
 (0)