mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix broken unit-test of webview (#36238)
This PR fixes the broken unit-test after [#35662](https://github.com/servo/servo/pull/35662) Testing: Verified locally and CI confirms too. Fixes: Migrate the test to use new API cc: @xiaochengh Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
This commit is contained in:
parent
4402b7cf8f
commit
520a7f7bc5
2 changed files with 11 additions and 9 deletions
|
@ -946,7 +946,7 @@ mod test {
|
||||||
BrowsingContextId, BrowsingContextIndex, PipelineNamespace, PipelineNamespaceId, WebViewId,
|
BrowsingContextId, BrowsingContextIndex, PipelineNamespace, PipelineNamespaceId, WebViewId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::webview::{UnknownWebView, WebViewAlreadyExists, WebViewManager};
|
use crate::webview::{UnknownWebView, WebViewManager};
|
||||||
|
|
||||||
fn top_level_id(namespace_id: u32, index: u32) -> WebViewId {
|
fn top_level_id(namespace_id: u32, index: u32) -> WebViewId {
|
||||||
WebViewId(BrowsingContextId {
|
WebViewId(BrowsingContextId {
|
||||||
|
@ -970,10 +970,13 @@ mod test {
|
||||||
PipelineNamespace::install(PipelineNamespaceId(0));
|
PipelineNamespace::install(PipelineNamespaceId(0));
|
||||||
let mut webviews = WebViewManager::default();
|
let mut webviews = WebViewManager::default();
|
||||||
|
|
||||||
// add() adds the webview to the map, but not the painting order.
|
// entry() adds the webview to the map, but not the painting order.
|
||||||
assert!(webviews.add(WebViewId::new(), 'a').is_ok());
|
webviews.entry(WebViewId::new()).or_insert('a');
|
||||||
assert!(webviews.add(WebViewId::new(), 'b').is_ok());
|
webviews.entry(WebViewId::new()).or_insert('b');
|
||||||
assert!(webviews.add(WebViewId::new(), 'c').is_ok());
|
webviews.entry(WebViewId::new()).or_insert('c');
|
||||||
|
assert!(webviews.get(top_level_id(0, 1)).is_some());
|
||||||
|
assert!(webviews.get(top_level_id(0, 2)).is_some());
|
||||||
|
assert!(webviews.get(top_level_id(0, 3)).is_some());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
webviews_sorted(&webviews),
|
webviews_sorted(&webviews),
|
||||||
vec![
|
vec![
|
||||||
|
@ -985,10 +988,8 @@ mod test {
|
||||||
assert!(webviews.painting_order.is_empty());
|
assert!(webviews.painting_order.is_empty());
|
||||||
|
|
||||||
// add() returns WebViewAlreadyExists if the webview id already exists.
|
// add() returns WebViewAlreadyExists if the webview id already exists.
|
||||||
assert_eq!(
|
webviews.entry(top_level_id(0, 3)).or_insert('d');
|
||||||
webviews.add(top_level_id(0, 3), 'd'),
|
assert!(webviews.get(top_level_id(0, 3)).is_some());
|
||||||
Err(WebViewAlreadyExists(top_level_id(0, 3)))
|
|
||||||
);
|
|
||||||
|
|
||||||
// Other methods return UnknownWebView or None if the webview id doesn’t exist.
|
// Other methods return UnknownWebView or None if the webview id doesn’t exist.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -162,6 +162,7 @@ class MachCommands(CommandBase):
|
||||||
self_contained_tests = [
|
self_contained_tests = [
|
||||||
"background_hang_monitor",
|
"background_hang_monitor",
|
||||||
"base",
|
"base",
|
||||||
|
"compositing",
|
||||||
"constellation",
|
"constellation",
|
||||||
"devtools",
|
"devtools",
|
||||||
"fonts",
|
"fonts",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue