OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 // These must match the files created in the C++ code. | 5 // These must match the files created in the C++ code. |
6 var EXPECTED_FILES_BEFORE = [ | 6 var EXPECTED_FILES_BEFORE = [ |
7 ['hello.txt', '123 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], | 7 ['hello.txt', '123 bytes', 'Plain text', 'Sep 4, 1998 12:34 PM'], |
8 ['world.mpeg', '1,000 bytes', 'MPEG video', 'Jul 4, 2012 10:35 AM'], | 8 ['world.mpeg', '1,000 bytes', 'MPEG video', 'Jul 4, 2012 10:35 AM'], |
9 ['My Desktop Background.png', '1 KB', 'PNG image', 'Jan 18, 2038 1:02 AM'], | 9 ['My Desktop Background.png', '1 KB', 'PNG image', 'Jan 18, 2038 1:02 AM'], |
10 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'] | 10 ['photos', '--', 'Folder', 'Jan 1, 1980 11:59 PM'] |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 else | 77 else |
78 window.setTimeout(helper, 50); | 78 window.setTimeout(helper, 50); |
79 }); | 79 }); |
80 } | 80 } |
81 helper(); | 81 helper(); |
82 } | 82 } |
83 | 83 |
84 // Checks that the files initially added by the C++ side are displayed, and | 84 // Checks that the files initially added by the C++ side are displayed, and |
85 // that a subsequently added file shows up. | 85 // that a subsequently added file shows up. |
86 function testFileDisplay() { | 86 function testFileDisplay() { |
87 getFileList(function(actualFilesBefore) { | 87 waitForFileListChange( |
88 chrome.test.assertEq(EXPECTED_FILES_BEFORE, actualFilesBefore); | 88 0, |
89 chrome.test.sendMessage('initial check done', function(reply) { | 89 function(actualFilesBefore) { |
90 chrome.test.assertEq('file added', reply); | 90 chrome.test.assertEq(EXPECTED_FILES_BEFORE, actualFilesBefore); |
91 waitForFileListChange( | 91 chrome.test.sendMessage('initial check done', function(reply) { |
92 chrome.test.assertEq('file added', reply); | |
93 waitForFileListChange( | |
92 EXPECTED_FILES_BEFORE.length, | 94 EXPECTED_FILES_BEFORE.length, |
93 chrome.test.callbackPass(function(actualFilesAfter) { | 95 chrome.test.callbackPass(function(actualFilesAfter) { |
94 chrome.test.assertEq(EXPECTED_FILES_AFTER, actualFilesAfter); | 96 chrome.test.assertEq(EXPECTED_FILES_AFTER, actualFilesAfter); |
95 })); | 97 })); |
98 }); | |
96 }); | 99 }); |
97 }); | |
98 } | 100 } |
99 | 101 |
100 // Injects the keyboard test code into the file manager tab and runs the | 102 // Injects the keyboard test code into the file manager tab and runs the |
101 // keyboard delete test. | 103 // keyboard delete test. |
102 function doKeyboardTestWithConfirmation(code) { | 104 function doKeyboardTestWithConfirmation(code) { |
103 chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { | 105 chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { |
satorux1
2013/04/05 08:15:11
fixed here too
| |
104 chrome.tabs.executeScript(null, {code: code}, function(result) { | 106 chrome.tabs.executeScript(null, {code: code}, function(result) { |
105 chrome.test.assertFalse(!result[0]); | 107 chrome.test.assertFalse(!result[0]); |
106 waitAndAcceptDialog(function() { | 108 waitAndAcceptDialog(function() { |
107 // Succeed here if anything happens; the C++ code checks what happened. | 109 // Succeed here if anything happens; the C++ code checks what happened. |
108 waitForFileListChange(EXPECTED_FILES_BEFORE.length, | 110 waitForFileListChange(EXPECTED_FILES_BEFORE.length, |
109 chrome.test.succeed); | 111 chrome.test.succeed); |
110 }); | 112 }); |
111 }); | 113 }); |
112 }); | 114 }); |
113 } | 115 } |
114 | 116 |
115 // Injects the keyboard test code into the file manager tab and runs the | 117 // Injects the keyboard test code into the file manager tab and runs the |
116 // keyboard copy test. | 118 // keyboard copy test. |
117 function doKeyboardTest(code) { | 119 function doKeyboardTest(code) { |
mtomasz
2013/04/05 07:59:44
I think this can also be flaky.
It can pass if co
mtomasz
2013/04/05 08:10:49
Actually it can even pass if the list is not yet i
satorux1
2013/04/05 08:15:11
Good idea! Done.
| |
118 chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { | 120 chrome.tabs.executeScript(null, {file: 'fake_keypress.js'}, function(result) { |
119 chrome.tabs.executeScript(null, {code: code}, function(result) { | 121 chrome.tabs.executeScript(null, {code: code}, function(result) { |
120 chrome.test.assertFalse(!result[0]); | 122 chrome.test.assertFalse(!result[0]); |
121 // Succeed here if anything happens; the C++ code checks what happened. | 123 // Succeed here if anything happens; the C++ code checks what happened. |
122 waitForFileListChange(EXPECTED_FILES_BEFORE.length, chrome.test.succeed); | 124 waitForFileListChange(EXPECTED_FILES_BEFORE.length, chrome.test.succeed); |
123 }); | 125 }); |
124 }); | 126 }); |
125 } | 127 } |
126 | 128 |
127 chrome.test.runTests([ | 129 chrome.test.runTests([ |
128 // Waits for the C++ code to send a string identifying a test, then runs that | 130 // Waits for the C++ code to send a string identifying a test, then runs that |
129 // test. | 131 // test. |
130 function testRunner() { | 132 function testRunner() { |
131 chrome.test.sendMessage('which test', function(reply) { | 133 chrome.test.sendMessage('which test', function(reply) { |
132 // These test names are provided by file_manager_browsertest.cc. | 134 // These test names are provided by file_manager_browsertest.cc. |
133 if (reply === 'file display') { | 135 if (reply === 'file display') { |
134 testFileDisplay(); | 136 testFileDisplay(); |
135 } else if (reply === 'keyboard copy') { | 137 } else if (reply === 'keyboard copy') { |
136 doKeyboardTest('fakeFileCopy("world.mpeg");'); | 138 doKeyboardTest('fakeFileCopy("world.mpeg");'); |
137 } else if (reply === 'keyboard delete') { | 139 } else if (reply === 'keyboard delete') { |
138 doKeyboardTestWithConfirmation('fakeFileDelete("world.mpeg");'); | 140 doKeyboardTestWithConfirmation('fakeFileDelete("world.mpeg");'); |
139 } else { | 141 } else { |
140 chrome.test.fail('Bogus test name passed to testRunner()'); | 142 chrome.test.fail('Bogus test name passed to testRunner()'); |
141 } | 143 } |
142 }); | 144 }); |
143 } | 145 } |
144 ]); | 146 ]); |
OLD | NEW |