Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / media_galleries / scan / test.js
blob21c061eca4ba95163d1bb0ee4fad1df3d72d17b1
1 // Copyright 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.
5 var mediaGalleries = chrome.mediaGalleries;
7 function MediaScanTest() {
8   var scanProgress = 'start';
9   var initialGalleryCount = 0;
11   function OnScanResultsAdded(galleries) {
12     chrome.test.assertEq(initialGalleryCount + 1, galleries.length);
13     chrome.test.succeed();
14   }
16   function OnScanProgress(details) {
17     chrome.test.assertEq(scanProgress, details.type);
18     if (scanProgress == 'start') {
19       scanProgress = 'finish';
20     } else {
21       scanProgress = 'done';
22       chrome.test.runWithUserGesture(function() {
23           mediaGalleries.addScanResults(OnScanResultsAdded);
24       });
25     }
26   }
28   function OnInitialMediaGalleries(galleries) {
29     initialGalleryCount = galleries.length;
30     mediaGalleries.onScanProgress.addListener(OnScanProgress);
31     mediaGalleries.startMediaScan();
32   }
34   mediaGalleries.getMediaFileSystems(OnInitialMediaGalleries);
37 CreateDummyWindowToPreventSleep();
39 chrome.test.runTests([
40   MediaScanTest,
41 ]);