Remove condition_with_duration for ModelHandle

Also, use a 2s timeout on CI for both `ModelHandle::condition` and
`ViewHandle::condition`.
This commit is contained in:
Antonio Scandurra
2021-05-19 14:50:28 +02:00
parent 830fc38503
commit 65cf9b7c1d
5 changed files with 15 additions and 38 deletions
+4 -12
View File
@@ -3011,9 +3011,7 @@ mod tests {
});
fs::remove_file(dir.path().join("file2")).unwrap();
buffer2
.condition_with_duration(Duration::from_millis(500), &app, |b, _| b.is_dirty())
.await;
buffer2.condition(&app, |b, _| b.is_dirty()).await;
assert_eq!(
*events.borrow(),
&[Event::Dirtied, Event::FileHandleChanged]
@@ -3038,9 +3036,7 @@ mod tests {
events.borrow_mut().clear();
fs::remove_file(dir.path().join("file3")).unwrap();
buffer3
.condition_with_duration(Duration::from_millis(500), &app, |_, _| {
!events.borrow().is_empty()
})
.condition(&app, |_, _| !events.borrow().is_empty())
.await;
assert_eq!(*events.borrow(), &[Event::FileHandleChanged]);
app.read(|ctx| assert!(buffer3.read(ctx).is_dirty()));
@@ -3095,9 +3091,7 @@ mod tests {
// contents are edited according to the diff between the old and new
// file contents.
buffer
.condition_with_duration(Duration::from_millis(500), &app, |buffer, _| {
buffer.text() != initial_contents
})
.condition(&app, |buffer, _| buffer.text() != initial_contents)
.await;
buffer.update(&mut app, |buffer, _| {
@@ -3131,9 +3125,7 @@ mod tests {
// Becaues the buffer is modified, it doesn't reload from disk, but is
// marked as having a conflict.
buffer
.condition_with_duration(Duration::from_millis(500), &app, |buffer, _| {
buffer.has_conflict()
})
.condition(&app, |buffer, _| buffer.has_conflict())
.await;
}
+4 -8
View File
@@ -1276,16 +1276,12 @@ impl WorktreeHandle for ModelHandle<Worktree> {
let tree = self.clone();
async move {
fs::write(root_path.join(filename), "").unwrap();
tree.condition_with_duration(Duration::from_secs(5), &app, |tree, _| {
tree.entry_for_path(filename).is_some()
})
.await;
tree.condition(&app, |tree, _| tree.entry_for_path(filename).is_some())
.await;
fs::remove_file(root_path.join(filename)).unwrap();
tree.condition_with_duration(Duration::from_secs(5), &app, |tree, _| {
tree.entry_for_path(filename).is_none()
})
.await;
tree.condition(&app, |tree, _| tree.entry_for_path(filename).is_none())
.await;
app.read(|ctx| tree.read(ctx).scan_complete()).await;
}