#include "components/page_load_metrics/browser/page_load_metrics_test_waiter.h"
#include "base/check_op.h"
#include "base/i18n/number_formatting.h"
#include "components/page_load_metrics/browser/observers/page_load_metrics_observer_tester.h"
#include "components/page_load_metrics/browser/page_load_metrics_observer.h"
#include "components/page_load_metrics/common/page_load_metrics.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
namespace page_load_metrics {
namespace {
template <class Set>
bool IsSubset(const Set& set1, const Set& set2) { … }
}
class WaiterMetricsObserver final : public PageLoadMetricsObserver { … };
std::string PageLoadMetricsTestWaiter::TimingFieldBitSet::ToDebugString()
const { … }
PageLoadMetricsTestWaiter::PageLoadMetricsTestWaiter(
content::WebContents* web_contents)
: … { … }
PageLoadMetricsTestWaiter::PageLoadMetricsTestWaiter(
content::WebContents* web_contents,
const char* observer_name_)
: … { … }
PageLoadMetricsTestWaiter::~PageLoadMetricsTestWaiter() { … }
void PageLoadMetricsTestWaiter::AddPageExpectation(TimingField field) { … }
void PageLoadMetricsTestWaiter::AddFrameSizeExpectation(const gfx::Size& size) { … }
void PageLoadMetricsTestWaiter::AddMainFrameIntersectionExpectation(
const gfx::Rect& rect) { … }
void PageLoadMetricsTestWaiter::SetMainFrameIntersectionExpectation() { … }
void PageLoadMetricsTestWaiter::SetMainFrameImageAdRectsExpectation() { … }
void PageLoadMetricsTestWaiter::AddMainFrameViewportRectExpectation(
const gfx::Rect& rect) { … }
void PageLoadMetricsTestWaiter::AddSubFrameExpectation(TimingField field) { … }
void PageLoadMetricsTestWaiter::AddWebFeatureExpectation(
blink::mojom::WebFeature web_feature) { … }
void PageLoadMetricsTestWaiter::AddUseCounterFeatureExpectation(
const blink::UseCounterFeature& feature) { … }
void PageLoadMetricsTestWaiter::AddSubframeNavigationExpectation() { … }
void PageLoadMetricsTestWaiter::AddSubframeDataExpectation() { … }
void PageLoadMetricsTestWaiter::AddMinimumCompleteResourcesExpectation(
int expected_minimum_complete_resources) { … }
void PageLoadMetricsTestWaiter::AddMinimumNetworkBytesExpectation(
int expected_minimum_network_bytes) { … }
void PageLoadMetricsTestWaiter::AddMinimumAggregateCpuTimeExpectation(
base::TimeDelta minimum) { … }
void PageLoadMetricsTestWaiter::AddMemoryUpdateExpectation(
content::GlobalRenderFrameHostId routing_id) { … }
void PageLoadMetricsTestWaiter::AddLoadingBehaviorExpectation(
int behavior_flags) { … }
void PageLoadMetricsTestWaiter::
AddMinimumLargestContentfulPaintImageExpectation(int expected_minimum) { … }
void PageLoadMetricsTestWaiter::AddMinimumLargestContentfulPaintTextExpectation(
int expected_minimum) { … }
void PageLoadMetricsTestWaiter::AddLargestContentfulPaintGreaterThanExpectation(
double timestamp) { … }
void PageLoadMetricsTestWaiter::AddPageLayoutShiftExpectation(
ShiftFrame shift_frame,
uint64_t num_layout_shifts) { … }
void PageLoadMetricsTestWaiter::AddSoftNavigationCountExpectation(
int expected_count) { … }
void PageLoadMetricsTestWaiter::AddOnCompleteCalledExpectation() { … }
bool PageLoadMetricsTestWaiter::DidObserveInPage(TimingField field) const { … }
bool PageLoadMetricsTestWaiter::DidObserveWebFeature(
blink::mojom::WebFeature feature) const { … }
bool PageLoadMetricsTestWaiter::DidObserveMainFrameImageAdRect(
const gfx::Rect& rect) const { … }
void PageLoadMetricsTestWaiter::Wait() { … }
void PageLoadMetricsTestWaiter::OnTimingUpdated(
content::RenderFrameHost* subframe_rfh,
const page_load_metrics::mojom::PageLoadTiming& timing) { … }
void PageLoadMetricsTestWaiter::OnSoftNavigationMetricsUpdated(
const page_load_metrics::mojom::SoftNavigationMetrics&
new_soft_navigation_metrics) { … }
void PageLoadMetricsTestWaiter::OnPageInputTimingUpdated(
uint64_t num_interactions) { … }
void PageLoadMetricsTestWaiter::OnCpuTimingUpdated(
content::RenderFrameHost* subframe_rfh,
const page_load_metrics::mojom::CpuTiming& timing) { … }
void PageLoadMetricsTestWaiter::OnLoadingBehaviorObserved(int behavior_flags) { … }
void PageLoadMetricsTestWaiter::OnLoadedResource(
const page_load_metrics::ExtraRequestCompleteInfo&
extra_request_complete_info) { … }
void PageLoadMetricsTestWaiter::OnResourceDataUseObserved(
content::RenderFrameHost* rfh,
const std::vector<page_load_metrics::mojom::ResourceDataUpdatePtr>&
resources) { … }
void PageLoadMetricsTestWaiter::OnFeaturesUsageObserved(
content::RenderFrameHost* rfh,
const std::vector<blink::UseCounterFeature>& features) { … }
void PageLoadMetricsTestWaiter::OnMainFrameIntersectionRectChanged(
content::RenderFrameHost* rfh,
const gfx::Rect& main_frame_intersection_rect) { … }
void PageLoadMetricsTestWaiter::OnMainFrameViewportRectChanged(
const gfx::Rect& main_frame_viewport_rect) { … }
void PageLoadMetricsTestWaiter::OnMainFrameImageAdRectsChanged(
const base::flat_map<int, gfx::Rect>& main_frame_image_ad_rects) { … }
void PageLoadMetricsTestWaiter::OnDidFinishSubFrameNavigation(
content::NavigationHandle* navigation_handle) { … }
void PageLoadMetricsTestWaiter::OnV8MemoryChanged(
const std::vector<MemoryUpdate>& memory_updates) { … }
void PageLoadMetricsTestWaiter::FrameSizeChanged(
content::RenderFrameHost* render_frame_host,
const gfx::Size& frame_size) { … }
void PageLoadMetricsTestWaiter::OnPageRenderDataUpdate(
const mojom::FrameRenderDataUpdate& render_data,
bool is_main_frame) { … }
void PageLoadMetricsTestWaiter::OnComplete(
const mojom::PageLoadTiming& timing) { … }
PageLoadMetricsTestWaiter::TimingFieldBitSet
PageLoadMetricsTestWaiter::GetMatchedBits(
const page_load_metrics::mojom::PageLoadTiming& timing,
const page_load_metrics::mojom::FrameMetadata& metadata) { … }
void PageLoadMetricsTestWaiter::OnTrackerCreated(
page_load_metrics::PageLoadTracker* tracker) { … }
void PageLoadMetricsTestWaiter::OnCommit(
page_load_metrics::PageLoadTracker* tracker) { … }
void PageLoadMetricsTestWaiter::OnActivate(
page_load_metrics::PageLoadTracker* tracker) { … }
void PageLoadMetricsTestWaiter::AddObserver(
page_load_metrics::PageLoadTracker* tracker) { … }
bool PageLoadMetricsTestWaiter::CpuTimeExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::LoadingBehaviorExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::ResourceUseExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::UseCounterExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::SubframeNavigationExpectationsSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::SubframeDataExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::MainFrameIntersectionExpectationsSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::MainFrameViewportRectExpectationsSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::MainFrameImageAdRectsExpectationsSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::MemoryUpdateExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::LayoutShiftExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::NumInteractionsExpectationsSatisfied() const { … }
bool PageLoadMetricsTestWaiter::NumLargestContentfulPaintImageSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::NumLargestContentfulPaintTextSatisfied() const { … }
bool PageLoadMetricsTestWaiter::
LargestContentfulPaintGreaterThanExpectationSatisfied() const { … }
bool PageLoadMetricsTestWaiter::SoftNavigationCountExpectationSatisfied()
const { … }
void PageLoadMetricsTestWaiter::AddSoftNavigationImageLCPExpectation(
int expected_soft_navigation_image_lcp_update) { … }
void PageLoadMetricsTestWaiter::AddSoftNavigationTextLCPExpectation(
int expected_soft_navigation_text_lcp_update) { … }
bool PageLoadMetricsTestWaiter::SoftNavigationImageLCPExpectationSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::SoftNavigationTextLCPExpectationSatisfied()
const { … }
bool PageLoadMetricsTestWaiter::ExpectationsSatisfied() const { … }
void PageLoadMetricsTestWaiter::AssertExpectationsSatisfied() const { … }
void PageLoadMetricsTestWaiter::ResetExpectations() { … }
const char* WaiterMetricsObserver::GetObserverName() const { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
WaiterMetricsObserver::OnFencedFramesStart(
content::NavigationHandle* navigation_handle,
const GURL& currently_committed_url) { … }
page_load_metrics::PageLoadMetricsObserver::ObservePolicy
WaiterMetricsObserver::OnPrerenderStart(
content::NavigationHandle* navigation_handle,
const GURL& currently_committed_url) { … }
void WaiterMetricsObserver::OnTimingUpdate(
content::RenderFrameHost* subframe_rfh,
const page_load_metrics::mojom::PageLoadTiming& timing) { … }
void WaiterMetricsObserver::OnSoftNavigationUpdated(
const mojom::SoftNavigationMetrics& soft_navigation_metrics) { … }
void WaiterMetricsObserver::OnPageInputTimingUpdate(uint64_t num_interactions) { … }
void WaiterMetricsObserver::OnCpuTimingUpdate(
content::RenderFrameHost* subframe_rfh,
const page_load_metrics::mojom::CpuTiming& timing) { … }
void WaiterMetricsObserver::OnLoadingBehaviorObserved(content::RenderFrameHost*,
int behavior_flags) { … }
void WaiterMetricsObserver::OnLoadedResource(
const page_load_metrics::ExtraRequestCompleteInfo&
extra_request_complete_info) { … }
void WaiterMetricsObserver::OnResourceDataUseObserved(
content::RenderFrameHost* rfh,
const std::vector<page_load_metrics::mojom::ResourceDataUpdatePtr>&
resources) { … }
void WaiterMetricsObserver::OnFeaturesUsageObserved(
content::RenderFrameHost* rfh,
const std::vector<blink::UseCounterFeature>& features) { … }
void WaiterMetricsObserver::OnMainFrameIntersectionRectChanged(
content::RenderFrameHost* rfh,
const gfx::Rect& main_frame_intersection_rect) { … }
void WaiterMetricsObserver::OnMainFrameViewportRectChanged(
const gfx::Rect& main_frame_viewport_rect) { … }
void WaiterMetricsObserver::OnMainFrameImageAdRectsChanged(
const base::flat_map<int, gfx::Rect>& main_frame_image_ad_rects) { … }
void WaiterMetricsObserver::OnDidFinishSubFrameNavigation(
content::NavigationHandle* navigation_handle) { … }
void WaiterMetricsObserver::FrameSizeChanged(
content::RenderFrameHost* render_frame_host,
const gfx::Size& frame_size) { … }
void WaiterMetricsObserver::OnV8MemoryChanged(
const std::vector<MemoryUpdate>& memory_updates) { … }
void WaiterMetricsObserver::OnPageRenderDataUpdate(
const mojom::FrameRenderDataUpdate& render_data,
bool is_main_frame) { … }
void WaiterMetricsObserver::OnComplete(const mojom::PageLoadTiming& timing) { … }
bool PageLoadMetricsTestWaiter::FrameSizeComparator::operator()(
const gfx::Size a,
const gfx::Size b) const { … }
PageLoadMetricsTestWaiter::State::State() = default;
PageLoadMetricsTestWaiter::State::~State() = default;
}