OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 'use strict'; | |
6 | |
7 /** | |
8 * Test sharing dialog for a file or directory on Drive | |
9 * @param {string} path Path for a file or a directory to be shared. | |
10 */ | |
11 function share(path) { | |
12 var appId; | |
13 StepsRunner.run([ | |
14 // Set up File Manager. | |
15 function() { | |
16 setupAndWaitUntilReady(null, RootPath.DRIVE, this.next); | |
17 }, | |
18 // Select the source file. | |
19 function(inAppId) { | |
20 appId = inAppId; | |
21 callRemoteTestUtil( | |
22 'selectFile', appId, [path], this.next); | |
23 }, | |
24 // Wait for the share button. | |
25 function(result) { | |
26 chrome.test.assertTrue(result); | |
27 waitForElement(appId, '#share-button:not([disabled])'). | |
28 then(this.next); | |
29 }, | |
30 // Invoke the share dialog. | |
31 function(result) { | |
32 callRemoteTestUtil('fakeMouseClick', | |
33 appId, | |
34 ['#share-button'], | |
35 this.next); | |
36 }, | |
37 // Wait until the share dialog's contents are shown. | |
38 function(result) { | |
39 chrome.test.assertTrue(result); | |
40 waitForElement(appId, '.share-dialog-webview-wrapper.loaded'). | |
41 then(this.next); | |
42 }, | |
43 function(result) { | |
44 chrome.test.assertTrue(!!result); | |
45 repeatUntil(function() { | |
46 return callRemoteTestUtil( | |
47 'queryAllElements', | |
48 appId, | |
49 [ | |
50 '.share-dialog-webview-wrapper.loaded', | |
51 null /* iframe */, | |
52 ['width', 'height'] | |
53 ]). | |
54 then(function(elements) { | |
55 // TODO(mtomasz): Fix the wrong geometry of the share dialog. | |
56 // return elements[0] && | |
57 // elements[0].styles.width === '350px' && | |
58 // elements[0].styles.height === '250px' ? | |
59 // undefined : | |
60 // pending('Dialog wrapper is currently %j. ' + | |
61 // 'but should be: 350x250', | |
62 // elements[0]); | |
63 return elements[0] ? | |
64 undefined : pending('The share dialog is not found.'); | |
65 }); | |
66 }). | |
67 then(this.next); | |
68 }, | |
69 // Wait until the share dialog's contents are shown. | |
70 function(result) { | |
71 callRemoteTestUtil('executeScriptInWebView', | |
72 appId, | |
73 ['.share-dialog-webview-wrapper.loaded webview', | |
74 'document.querySelector("button").click()'], | |
75 this.next); | |
76 }, | |
77 // Wait until the share dialog's contents are hidden. | |
78 function(result) { | |
79 chrome.test.assertTrue(!!result); | |
80 waitForElementLost(appId, '.share-dialog-webview-wrapper.loaded'). | |
81 then(this.next); | |
82 }, | |
83 // Check for Javascript errros. | |
84 function() { | |
85 checkIfNoErrorsOccured(this.next); | |
86 } | |
87 ]); | |
88 }; | |
89 | |
90 /** | |
91 * Tests sharing a file on Drive | |
92 */ | |
93 testcase.shareFile = share.bind(null, 'world.ogv'); | |
94 | |
95 /** | |
96 * Tests sharing a directory on Drive | |
97 */ | |
98 testcase.shareDirectory = share.bind(null, 'photos'); | |
OLD | NEW |