@@ -109,6 +109,28 @@ impl HasDisplayHandle for CreationContext<'_> {
109
109
}
110
110
}
111
111
112
+ impl CreationContext < ' _ > {
113
+ /// Create a new empty [CreationContext] for testing [App]s in kittest.
114
+ #[ doc( hidden) ]
115
+ pub fn _new_kittest ( egui_ctx : egui:: Context ) -> Self {
116
+ Self {
117
+ egui_ctx,
118
+ integration_info : IntegrationInfo :: mock ( ) ,
119
+ storage : None ,
120
+ #[ cfg( feature = "glow" ) ]
121
+ gl : None ,
122
+ #[ cfg( feature = "glow" ) ]
123
+ get_proc_address : None ,
124
+ #[ cfg( feature = "wgpu" ) ]
125
+ wgpu_render_state : None ,
126
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
127
+ raw_window_handle : Err ( HandleError :: NotSupported ) ,
128
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
129
+ raw_display_handle : Err ( HandleError :: NotSupported ) ,
130
+ }
131
+ }
132
+ }
133
+
112
134
// ----------------------------------------------------------------------------
113
135
114
136
/// Implement this trait to write apps that can be compiled for both web/wasm and desktop/native using [`eframe`](https://github.com/emilk/egui/tree/master/crates/eframe).
@@ -617,7 +639,8 @@ pub struct Frame {
617
639
618
640
/// Can be used to manage GPU resources for custom rendering with WGPU using [`egui::PaintCallback`]s.
619
641
#[ cfg( feature = "wgpu" ) ]
620
- pub ( crate ) wgpu_render_state : Option < egui_wgpu:: RenderState > ,
642
+ #[ doc( hidden) ]
643
+ pub wgpu_render_state : Option < egui_wgpu:: RenderState > ,
621
644
622
645
/// Raw platform window handle
623
646
#[ cfg( not( target_arch = "wasm32" ) ) ]
@@ -651,6 +674,25 @@ impl HasDisplayHandle for Frame {
651
674
}
652
675
653
676
impl Frame {
677
+ /// Create a new empty [Frame] for testing [App]s in kittest.
678
+ #[ doc( hidden) ]
679
+ pub fn _new_kittest ( ) -> Self {
680
+ Self {
681
+ #[ cfg( feature = "glow" ) ]
682
+ gl : None ,
683
+ #[ cfg( all( feature = "glow" , not( target_arch = "wasm32" ) ) ) ]
684
+ glow_register_native_texture : None ,
685
+ info : IntegrationInfo :: mock ( ) ,
686
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
687
+ raw_display_handle : Err ( HandleError :: NotSupported ) ,
688
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
689
+ raw_window_handle : Err ( HandleError :: NotSupported ) ,
690
+ storage : None ,
691
+ #[ cfg( feature = "wgpu" ) ]
692
+ wgpu_render_state : None ,
693
+ }
694
+ }
695
+
654
696
/// True if you are in a web environment.
655
697
///
656
698
/// Equivalent to `cfg!(target_arch = "wasm32")`
@@ -794,6 +836,29 @@ pub struct IntegrationInfo {
794
836
pub cpu_usage : Option < f32 > ,
795
837
}
796
838
839
+ impl IntegrationInfo {
840
+ fn mock ( ) -> Self {
841
+ Self {
842
+ #[ cfg( target_arch = "wasm32" ) ]
843
+ web_info : WebInfo {
844
+ user_agent : "kittest" . to_owned ( ) ,
845
+ location : Location {
846
+ url : "http://localhost" . to_owned ( ) ,
847
+ protocol : "http:" . to_owned ( ) ,
848
+ host : "localhost" . to_owned ( ) ,
849
+ hostname : "localhost" . to_owned ( ) ,
850
+ port : "80" . to_owned ( ) ,
851
+ hash : String :: new ( ) ,
852
+ query : String :: new ( ) ,
853
+ query_map : Default :: default ( ) ,
854
+ origin : "http://localhost" . to_owned ( ) ,
855
+ } ,
856
+ } ,
857
+ cpu_usage : None ,
858
+ }
859
+ }
860
+ }
861
+
797
862
// ----------------------------------------------------------------------------
798
863
799
864
/// A place where you can store custom data in a way that persists when you restart the app.
0 commit comments