Pass the UIProvider to FileManager::handle() as needed.

This commit is contained in:
Ms2ger 2016-11-18 13:09:23 +01:00
parent f672bf9eab
commit ae1340bf50
6 changed files with 88 additions and 94 deletions

View file

@ -26,7 +26,7 @@ impl UIProvider for TestProvider {
#[test]
fn test_filemanager() {
let filemanager = FileManager::new(TEST_PROVIDER);
let filemanager = FileManager::new();
// Try to open a dummy file "tests/unit/net/test.jpeg" in tree
let mut handler = File::open("test.jpeg").expect("test.jpeg is stolen");
@ -41,7 +41,8 @@ fn test_filemanager() {
{
// Try to select a dummy file "tests/unit/net/test.jpeg"
let (tx, rx) = ipc::channel().unwrap();
filemanager.handle(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone(), None), None);
filemanager.handle(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone(), None),
None, TEST_PROVIDER);
let selected = rx.recv().expect("Broken channel")
.expect("The file manager failed to find test.jpeg");
@ -52,7 +53,8 @@ fn test_filemanager() {
// Test by reading, expecting same content
{
let (tx2, rx2) = ipc::channel().unwrap();
filemanager.handle(FileManagerThreadMsg::ReadFile(tx2, selected.id.clone(), false, origin.clone()), None);
filemanager.handle(FileManagerThreadMsg::ReadFile(tx2, selected.id.clone(), false, origin.clone()),
None, TEST_PROVIDER);
let msg = rx2.recv().expect("Broken channel");
@ -82,7 +84,8 @@ fn test_filemanager() {
// Delete the id
{
let (tx2, rx2) = ipc::channel().unwrap();
filemanager.handle(FileManagerThreadMsg::DecRef(selected.id.clone(), origin.clone(), tx2), None);
filemanager.handle(FileManagerThreadMsg::DecRef(selected.id.clone(), origin.clone(), tx2),
None, TEST_PROVIDER);
let ret = rx2.recv().expect("Broken channel");
assert!(ret.is_ok(), "DecRef is not okay");
@ -91,7 +94,8 @@ fn test_filemanager() {
// Test by reading again, expecting read error because we invalidated the id
{
let (tx2, rx2) = ipc::channel().unwrap();
filemanager.handle(FileManagerThreadMsg::ReadFile(tx2, selected.id.clone(), false, origin.clone()), None);
filemanager.handle(FileManagerThreadMsg::ReadFile(tx2, selected.id.clone(), false, origin.clone()),
None, TEST_PROVIDER);
let msg = rx2.recv().expect("Broken channel");