Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9246 from NejcZdovc/hotfix/#9244-download
Browse files Browse the repository at this point in the history
Fixes pause/resume for download items
  • Loading branch information
bsclifton committed Jun 6, 2017
1 parent 520a764 commit 490e65e
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 8 deletions.
2 changes: 0 additions & 2 deletions app/browser/reducers/downloadsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ const downloadsReducer = (state, action) => {
break
case PAUSE:
pauseDownload(action.downloadId)
state = state.setIn(['downloads', action.downloadId, 'state'], downloadStates.PAUSED)
break
case RESUME:
resumeDownload(action.downloadId)
state = state.setIn(['downloads', action.downloadId, 'state'], downloadStates.IN_PROGRESS)
break
}
break
Expand Down
6 changes: 1 addition & 5 deletions app/filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,7 @@ function registerForDownloadListener (session) {
win.webContents.send(messages.SHOW_DOWNLOADS_TOOLBAR)
}
item.on('updated', function () {
let state = downloadStates.IN_PROGRESS
const downloadItem = appStore.getState().getIn(['downloads', downloadId])
if (downloadItem && downloadItem.get('state') === downloadStates.PAUSED) {
state = downloadStates.PAUSED
}
const state = item.isPaused() ? downloadStates.PAUSED : downloadStates.IN_PROGRESS
updateDownloadState(downloadId, item, state)
})
item.on('done', function (e, state) {
Expand Down
13 changes: 12 additions & 1 deletion test/lib/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,16 @@ module.exports = {
msgBoxSuppress: '[data-test-id^="msgBoxTab_"] .switchMiddle',
msgBoxSuppressTrue: '[data-test-id^="msgBoxTab_"] .switchMiddle .switchBackground.switchedOn',
msgBoxMessage: '[data-test-id="msgBoxMessage"]',
msgBoxTitle: '[data-test-id="msgBoxTitle"]'
msgBoxTitle: '[data-test-id="msgBoxTitle"]',

// download
downloadBar: '.downloadsBar',
downloadItem: '.downloadItem',
downloadPause: '[data-test-id="pauseButton"]',
downloadResume: '[data-test-id="resumeButton"]',
downloadCancel: '[data-test-id="cancelButton"]',
downloadReDownload: '[data-test-id="redownloadButton"]',
downloadDelete: '[data-test-id="deleteButton"]',
downloadDeleteConfirm: '[data-test-id="confirmDeleteButton"]',
downloadRemoveFromList: '[data-test-id="downloadRemoveFromList"]'
}
98 changes: 98 additions & 0 deletions test/misc-components/downloadItemTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global describe, it, before */

const Brave = require('../lib/brave')
const {
urlInput,
downloadBar,
downloadItem,
downloadPause,
downloadResume,
downloadCancel,
downloadReDownload,
downloadRemoveFromList,
downloadDelete,
downloadDeleteConfirm
} = require('../lib/selectors')

function * setup (client) {
yield client
.waitForUrl(Brave.newTabUrl)
.waitForBrowserWindow()
.waitForVisible(urlInput)
}

describe('downloadItem test', function () {
Brave.beforeAll(this)
before(function * () {
this.downloadSite = 'http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-desktop-amd64.iso'
yield setup(this.app.client)

yield this.app.client
.waitForUrl(Brave.newTabUrl)
.url(this.downloadSite)
})

it('check if download bar is shown', function * () {
yield this.app.client
.windowByUrl(Brave.browserWindowUrl)
.waitForElementCount(downloadBar, 1)
})

it('check if you can pause download', function * () {
yield this.app.client
.moveToObject(downloadItem)
.waitForElementCount(downloadPause, 1)
.click(downloadPause)
.waitForElementCount(downloadResume, 1)
})

it('check if you can resume download', function * () {
yield this.app.client
.waitForElementCount(downloadResume, 1)
.click(downloadResume)
.waitForElementCount(downloadPause, 1)
})

it('check if you can cancel download', function * () {
yield this.app.client
.waitForElementCount(downloadPause, 1)
.click(downloadCancel)
.waitForElementCount(downloadReDownload, 1)
})

it('check if you can re-download', function * () {
yield this.app.client
.waitForElementCount(downloadReDownload, 1)
.click(downloadReDownload)
.waitForElementCount(downloadPause, 1)
})

it('check if you can remove item from the list', function * () {
yield this.app.client
.moveToObject(downloadItem)
.waitForElementCount(downloadPause, 1)
.click(downloadCancel)
.waitForElementCount(downloadReDownload, 1)
.click(downloadRemoveFromList)
.waitForElementCount(downloadBar, 0)
})

it('check if you can delete downloaded item', function * () {
yield this.app.client
.tabByIndex(0)
.url(this.downloadSite)
.windowByUrl(Brave.browserWindowUrl)
.waitForElementCount(downloadBar, 1)
.moveToObject(downloadItem)
.waitForElementCount(downloadPause, 1)
.click(downloadCancel)
.waitForElementCount(downloadReDownload, 1)
.click(downloadDelete)
.waitForElementCount(downloadDeleteConfirm, 1)
.click(downloadDeleteConfirm)
.waitForElementCount(downloadBar, 0)
})
})

0 comments on commit 490e65e

Please sign in to comment.