mirror of
https://github.com/servo/servo.git
synced 2025-08-18 11:55:39 +01:00
Made PipelineId non-zero, so optional ids take no more space.
This commit is contained in:
parent
a0afa66dbe
commit
6754b2834f
11 changed files with 79 additions and 33 deletions
|
@ -8,7 +8,7 @@ use gfx::display_list::{DisplayItem, DisplayList, ImageDisplayItem};
|
|||
use gfx_traits::Epoch;
|
||||
use ipc_channel::ipc;
|
||||
use metrics::{PaintTimeMetrics, ProfilerMetadataFactory};
|
||||
use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId};
|
||||
use msg::constellation_msg::TEST_PIPELINE_ID;
|
||||
use net_traits::image::base::PixelFormat;
|
||||
use profile_traits::time::{ProfilerChan, TimerMetadata};
|
||||
use style::computed_values::image_rendering;
|
||||
|
@ -23,30 +23,22 @@ impl ProfilerMetadataFactory for DummyProfilerMetadataFactory {
|
|||
|
||||
#[test]
|
||||
fn test_paint_metrics_construction() {
|
||||
let pipeline_id = PipelineId {
|
||||
namespace_id: PipelineNamespaceId(1),
|
||||
index: PipelineIndex(1),
|
||||
};
|
||||
let (sender, _) = ipc::channel().unwrap();
|
||||
let profiler_chan = ProfilerChan(sender);
|
||||
let (layout_sender, _) = ipc::channel().unwrap();
|
||||
let (script_sender, _) = ipc::channel().unwrap();
|
||||
let paint_time_metrics = PaintTimeMetrics::new(pipeline_id, profiler_chan, layout_sender, script_sender);
|
||||
let paint_time_metrics = PaintTimeMetrics::new(TEST_PIPELINE_ID, profiler_chan, layout_sender, script_sender);
|
||||
assert_eq!(paint_time_metrics.get_navigation_start(), None, "navigation start is None");
|
||||
assert_eq!(paint_time_metrics.get_first_paint(), None, "first paint is None");
|
||||
assert_eq!(paint_time_metrics.get_first_contentful_paint(), None, "first contentful paint is None");
|
||||
}
|
||||
|
||||
fn test_common(display_list: &DisplayList, epoch: Epoch) -> PaintTimeMetrics {
|
||||
let pipeline_id = PipelineId {
|
||||
namespace_id: PipelineNamespaceId(1),
|
||||
index: PipelineIndex(1),
|
||||
};
|
||||
let (sender, _) = ipc::channel().unwrap();
|
||||
let profiler_chan = ProfilerChan(sender);
|
||||
let (layout_sender, _) = ipc::channel().unwrap();
|
||||
let (script_sender, _) = ipc::channel().unwrap();
|
||||
let mut paint_time_metrics = PaintTimeMetrics::new(pipeline_id, profiler_chan, layout_sender, script_sender);
|
||||
let mut paint_time_metrics = PaintTimeMetrics::new(TEST_PIPELINE_ID, profiler_chan, layout_sender, script_sender);
|
||||
let dummy_profiler_metadata_factory = DummyProfilerMetadataFactory {};
|
||||
|
||||
paint_time_metrics.maybe_observe_paint_time(&dummy_profiler_metadata_factory,
|
||||
|
@ -81,12 +73,8 @@ fn test_first_paint_setter() {
|
|||
|
||||
#[test]
|
||||
fn test_first_contentful_paint_setter() {
|
||||
let pipeline_id = PipelineId {
|
||||
namespace_id: PipelineNamespaceId(1),
|
||||
index: PipelineIndex(1),
|
||||
};
|
||||
let image = DisplayItem::Image(Box::new(ImageDisplayItem {
|
||||
base: BaseDisplayItem::empty(pipeline_id),
|
||||
base: BaseDisplayItem::empty(TEST_PIPELINE_ID),
|
||||
webrender_image: WebRenderImageInfo {
|
||||
width: 1,
|
||||
height: 1,
|
||||
|
|
14
tests/unit/msg/Cargo.toml
Normal file
14
tests/unit/msg/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "msg_tests"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
name = "msg_tests"
|
||||
path = "lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
msg = {path = "../../../components/msg"}
|
||||
size_of_test = {path = "../../../components/size_of_test"}
|
8
tests/unit/msg/lib.rs
Normal file
8
tests/unit/msg/lib.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
extern crate msg;
|
||||
#[macro_use] extern crate size_of_test;
|
||||
|
||||
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;
|
14
tests/unit/msg/size_of.rs
Normal file
14
tests/unit/msg/size_of.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use msg::constellation_msg::BrowsingContextId;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use msg::constellation_msg::TopLevelBrowsingContextId;
|
||||
|
||||
size_of_test!(test_size_of_pipeline_id, PipelineId, 8);
|
||||
size_of_test!(test_size_of_optional_pipeline_id, Option<PipelineId>, 8);
|
||||
size_of_test!(test_size_of_browsing_context_id, BrowsingContextId, 8);
|
||||
size_of_test!(test_size_of_optional_browsing_context_id, Option<BrowsingContextId>, 8);
|
||||
size_of_test!(test_size_of_top_level_browsing_context_id, TopLevelBrowsingContextId, 8);
|
||||
size_of_test!(test_size_of_top_level_optional_browsing_context_id, Option<TopLevelBrowsingContextId>, 8);
|
Loading…
Add table
Add a link
Reference in a new issue