Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: chrome/test/data/extensions/api_test/automation/tests/desktop/hit_test.js

Issue 2900803003: Automation API hit test should automatically convert to integer coordinates. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/automation/sites/hit_test.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var allTests = [ 5 var allTests = [
6 function testHitTestInDesktop() { 6 function testHitTestInDesktop() {
7 var url = 'data:text/html,<!doctype html>' + 7 var url = 'data:text/html,<!doctype html>' +
8 encodeURI('<button>Click Me</button>'); 8 encodeURI('<button>Click Me</button>');
9 var didHitTest = false; 9 var didHitTest = false;
10 chrome.automation.getDesktop(function(desktop) { 10 chrome.automation.getDesktop(function(desktop) {
11 chrome.tabs.create({url: url}); 11 chrome.tabs.create({url: url});
12 12
13 desktop.addEventListener('loadComplete', function(event) { 13 desktop.addEventListener('loadComplete', function(event) {
14 if (didHitTest) 14 if (didHitTest)
15 return; 15 return;
16 if (event.target.url.indexOf('data:') >= 0) { 16 if (event.target.url.indexOf('data:') >= 0) {
17 var button = desktop.find({ attributes: { name: 'Click Me' } }); 17 var button = desktop.find({ attributes: { name: 'Click Me' } });
18 if (button) { 18 if (button) {
19 didHitTest = true; 19 didHitTest = true;
20 button.addEventListener(EventType.ALERT, function() { 20 button.addEventListener(EventType.ALERT, function() {
21 chrome.test.succeed(); 21 chrome.test.succeed();
22 }, true); 22 }, true);
23 var cx = Math.floor( 23 var cx = button.location.left + button.location.width / 2;
24 button.location.left + button.location.width / 2); 24 var cy = button.location.top + button.location.height / 2;
25 var cy = Math.floor(
26 button.location.top + button.location.height / 2);
27 desktop.hitTest(cx, cy, EventType.ALERT); 25 desktop.hitTest(cx, cy, EventType.ALERT);
28 } 26 }
29 } 27 }
30 }, false); 28 }, false);
31 }); 29 });
32 }, 30 },
33 ]; 31 ];
34 32
35 chrome.test.runTests(allTests); 33 chrome.test.runTests(allTests);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/automation/sites/hit_test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698