forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a stub cloud import banner.
This CL adds a stub cloud import banner shown only on DCIM directories on volumes eligible for import. TEST=Tested manually. BUG=451658 Review URL: https://codereview.chromium.org/873913003 Cr-Commit-Position: refs/heads/master@{#313313}
- Loading branch information
1 parent
043786d
commit da4f04d
Showing
9 changed files
with
321 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
ui/file_manager/file_manager/foreground/js/ui/banners_unittest.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<!-- Copyright 2015 The Chromium Authors. All rights reserved. | ||
-- Use of this source code is governed by a BSD-style license that can be | ||
-- found in the LICENSE file. | ||
--> | ||
|
||
<html> | ||
<body> | ||
<script src="../../../../../../ui/webui/resources/js/cr.js"></script> | ||
<script src="../../../../../../ui/webui/resources/js/cr/event_target.js"></script> | ||
<script src="../../../../../../ui/webui/resources/js/cr/ui.js"></script> | ||
<script src="../../../../../../ui/webui/resources/js/cr/ui/array_data_model.js"></script> | ||
<script src="../../../../../../ui/webui/resources/js/load_time_data.js"></script> | ||
|
||
<script src="../../../common/js/async_util.js"></script> | ||
<script src="../../../common/js/mock_entry.js"></script> | ||
<script src="../../../common/js/unittest_util.js"></script> | ||
<script src="../../../common/js/util.js"></script> | ||
<script src="../../../common/js/volume_manager_common.js"></script> | ||
<script src="../../../common/js/importer_common.js"></script> | ||
<script src="../../../background/js/mock_volume_manager.js"></script> | ||
<script src="../../../background/js/volume_manager.js"></script> | ||
<script src="../mock_directory_model.js"></script> | ||
<script src="banners.js"></script> | ||
|
||
<script src="banners_unittest.js"></script> | ||
|
||
<!-- Stub DOM structure for the banner. --> | ||
<div id="cloud-import-banner" hidden> | ||
<div id="cloud-import-banner-close"></div> | ||
</div> | ||
</body> | ||
</html> |
88 changes: 88 additions & 0 deletions
88
ui/file_manager/file_manager/foreground/js/ui/banners_unittest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
loadTimeData.data = { | ||
DOWNLOADS_DIRECTORY_LABEL: 'Downloads', | ||
DRIVE_DIRECTORY_LABEL: 'Google Drive', | ||
DRIVE_MY_DRIVE_LABEL: 'My Drive', | ||
DRIVE_OFFLINE_COLLECTION_LABEL: 'Offline', | ||
DRIVE_SHARED_WITH_ME_COLLECTION_LABEL: 'Shared with me', | ||
DRIVE_RECENT_COLLECTION_LABEL: 'Recent', | ||
REMOVABLE_DIRECTORY_LABEL: 'External Storage', | ||
ARCHIVE_DIRECTORY_LABEL: 'Archives' | ||
}; | ||
|
||
/** @type {!MockVolumeManager|undefined} */ | ||
var volumeManager; | ||
|
||
/** @type {!MockDirectoryModel|undefined} */ | ||
var directoryModel; | ||
|
||
/** @type {!MockChromeStorageAPI|undefined} */ | ||
var storageAPI; | ||
|
||
/** @type {!MockDirectoryEntyr|undefined} */ | ||
var mtpDcimEntry; | ||
|
||
/** @type {!MockDirectoryEntry|undefined} */ | ||
var downloadsEntry; | ||
|
||
/** @type {!CloudImportBanner|undefined} */ | ||
var cloudImportBanner; | ||
|
||
/** @type {!Element|undefined} */ | ||
var cloudImportBannerDiv; | ||
|
||
/** @type {!Element|undefined} */ | ||
var cloudImportBannerCloseDiv; | ||
|
||
function setUp() { | ||
volumeManager = new MockVolumeManagerWrapper(); | ||
directoryModel = new MockDirectoryModel(); | ||
storageAPI = new MockChromeStorageAPI(); | ||
|
||
var mtpVolumeInfo = volumeManager.createVolumeInfo( | ||
VolumeManagerCommon.VolumeType.MTP, 'mtp:test', 'Magic Space Phone'); | ||
mtpDcimEntry = new MockDirectoryEntry(mtpVolumeInfo.fileSystem, '/DCIM'); | ||
downloadsEntry = new MockDirectoryEntry( | ||
volumeManager.getCurrentProfileVolumeInfo( | ||
VolumeManagerCommon.VolumeType.DOWNLOADS), | ||
'/hello-world'); | ||
|
||
cloudImportBanner = new CloudImportBanner(directoryModel, volumeManager); | ||
cloudImportBannerDiv = document.querySelector('#cloud-import-banner'); | ||
cloudImportBannerCloseDiv = document.querySelector( | ||
'#cloud-import-banner-close'); | ||
} | ||
|
||
function testIfCloudImportBannerOnDirectoryChanged(callback) { | ||
assertTrue(cloudImportBannerDiv.hidden); | ||
reportPromise(directoryModel.navigateToMockEntry(mtpDcimEntry) | ||
.then(function() { | ||
assertFalse(cloudImportBannerDiv.hidden); | ||
return directoryModel.navigateToMockEntry(downloadsEntry); | ||
}) | ||
.then(function() { | ||
assertTrue(cloudImportBannerDiv.hidden); | ||
}), callback); | ||
} | ||
|
||
function testIfCloudImportBannerDiscard(callback) { | ||
assertTrue(cloudImportBannerDiv.hidden); | ||
reportPromise(directoryModel.navigateToMockEntry(mtpDcimEntry) | ||
.then(function() { | ||
assertFalse(cloudImportBannerDiv.hidden); | ||
cloudImportBannerCloseDiv.click(); | ||
}) | ||
.then(function() { | ||
assertTrue(cloudImportBannerDiv.hidden) | ||
// Go back to downloads, and again to an eligible directory. | ||
return directoryModel.navigateToMockEntry(downloadsEntry).then( | ||
directoryModel.navigateToMockEntry(mtpDcimEntry)); | ||
}) | ||
.then(function() { | ||
// Should not show up. | ||
assertTrue(cloudImportBannerDiv.hidden); | ||
}), callback); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters