// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PAGE_LOAD_METRICS_RENDERER_FAKE_PAGE_TIMING_SENDER_H_ #define COMPONENTS_PAGE_LOAD_METRICS_RENDERER_FAKE_PAGE_TIMING_SENDER_H_ #include <set> #include <vector> #include "base/memory/raw_ptr.h" #include "components/page_load_metrics/common/page_load_metrics.mojom.h" #include "components/page_load_metrics/common/page_load_timing.h" #include "components/page_load_metrics/renderer/page_timing_sender.h" #include "third_party/blink/public/common/use_counter/use_counter_feature.h" namespace page_load_metrics { // PageTimingSender implementation for use in tests. Allows for setting and // verifying basic expectations when sending PageLoadTiming. By default, // FakePageTimingSender will verify that expected and actual // PageLoadTimings match on each invocation to ExpectPageLoadTiming() and // SendTiming(), as well as in the destructor. Tests can force additional // validations by calling VerifyExpectedTimings. // // Expected PageLoadTimings are specified via ExpectPageLoadTiming, and actual // PageLoadTimings are dispatched through SendTiming(). When SendTiming() is // called, we verify that the actual PageLoadTimings dipatched through // SendTiming() match the expected PageLoadTimings provided via // ExpectPageLoadTiming. // // Normally, gmock would be used in place of this class, but gmock is not // compatible with structures that use aligned memory, and PageLoadTiming uses // std::optional which uses aligned memory, so we're forced to roll // our own implementation here. See // https://groups.google.com/forum/#!topic/googletestframework/W-Hud3j_c6I for // more details. class FakePageTimingSender : public PageTimingSender { … }; } // namespace page_load_metrics #endif // COMPONENTS_PAGE_LOAD_METRICS_RENDERER_FAKE_PAGE_TIMING_SENDER_H_