ai: Add an eval for the inline assistant (#43291)
Release Notes: - N/A --------- Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
co-authored by
Mikayla Maki
parent
92dcfdef76
commit
290a1550aa
@@ -551,12 +551,39 @@ impl SystemWindowTabController {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum GpuiMode {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
Test {
|
||||
skip_drawing: bool,
|
||||
},
|
||||
Production,
|
||||
}
|
||||
|
||||
impl GpuiMode {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn test() -> Self {
|
||||
GpuiMode::Test {
|
||||
skip_drawing: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn skip_drawing(&self) -> bool {
|
||||
match self {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
GpuiMode::Test { skip_drawing } => *skip_drawing,
|
||||
GpuiMode::Production => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Contains the state of the full application, and passed as a reference to a variety of callbacks.
|
||||
/// Other [Context] derefs to this type.
|
||||
/// You need a reference to an `App` to access the state of a [Entity].
|
||||
pub struct App {
|
||||
pub(crate) this: Weak<AppCell>,
|
||||
pub(crate) platform: Rc<dyn Platform>,
|
||||
pub(crate) mode: GpuiMode,
|
||||
text_system: Arc<TextSystem>,
|
||||
flushing_effects: bool,
|
||||
pending_updates: usize,
|
||||
@@ -635,6 +662,7 @@ impl App {
|
||||
this: this.clone(),
|
||||
platform: platform.clone(),
|
||||
text_system,
|
||||
mode: GpuiMode::Production,
|
||||
actions: Rc::new(ActionRegistry::default()),
|
||||
flushing_effects: false,
|
||||
pending_updates: 0,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels,
|
||||
Platform, Point, Render, Result, Size, Task, TestDispatcher, TestPlatform,
|
||||
TestScreenCaptureSource, TestWindow, TextSystem, VisualContext, Window, WindowBounds,
|
||||
WindowHandle, WindowOptions,
|
||||
WindowHandle, WindowOptions, app::GpuiMode,
|
||||
};
|
||||
use anyhow::{anyhow, bail};
|
||||
use futures::{Stream, StreamExt, channel::oneshot};
|
||||
@@ -132,8 +132,11 @@ impl TestAppContext {
|
||||
let http_client = http_client::FakeHttpClient::with_404_response();
|
||||
let text_system = Arc::new(TextSystem::new(platform.text_system()));
|
||||
|
||||
let mut app = App::new_app(platform.clone(), asset_source, http_client);
|
||||
app.borrow_mut().mode = GpuiMode::test();
|
||||
|
||||
Self {
|
||||
app: App::new_app(platform.clone(), asset_source, http_client),
|
||||
app,
|
||||
background_executor,
|
||||
foreground_executor,
|
||||
dispatcher,
|
||||
@@ -144,6 +147,11 @@ impl TestAppContext {
|
||||
}
|
||||
}
|
||||
|
||||
/// Skip all drawing operations for the duration of this test.
|
||||
pub fn skip_drawing(&mut self) {
|
||||
self.app.borrow_mut().mode = GpuiMode::Test { skip_drawing: true };
|
||||
}
|
||||
|
||||
/// Create a single TestAppContext, for non-multi-client tests
|
||||
pub fn single() -> Self {
|
||||
let dispatcher = TestDispatcher::new(StdRng::seed_from_u64(0));
|
||||
|
||||
@@ -2006,7 +2006,9 @@ impl Window {
|
||||
if let Some(input_handler) = self.platform_window.take_input_handler() {
|
||||
self.rendered_frame.input_handlers.push(Some(input_handler));
|
||||
}
|
||||
self.draw_roots(cx);
|
||||
if !cx.mode.skip_drawing() {
|
||||
self.draw_roots(cx);
|
||||
}
|
||||
self.dirty_views.clear();
|
||||
self.next_frame.window_active = self.active.get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user