Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Side by Side Diff: chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h

Issue 2091353002: Generalize the reload PLMO to support other transition types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER_TE ST_HARNESS_H_ 5 #ifndef CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER_TE ST_HARNESS_H_
6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER_TE ST_HARNESS_H_ 6 #define CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER_TE ST_HARNESS_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/test/histogram_tester.h" 9 #include "base/test/histogram_tester.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
11 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h" 11 #include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
12 #include "content/public/test/web_contents_tester.h" 12 #include "content/public/test/web_contents_tester.h"
13 #include "third_party/WebKit/public/web/WebInputEvent.h" 13 #include "third_party/WebKit/public/web/WebInputEvent.h"
14 #include "ui/base/page_transition_types.h"
14 15
15 namespace page_load_metrics { 16 namespace page_load_metrics {
16 17
17 // This class can be used to drive tests of PageLoadMetricsObservers. To hook up 18 // This class can be used to drive tests of PageLoadMetricsObservers. To hook up
18 // an observer, override RegisterObservers and call tracker->AddObserver. This 19 // an observer, override RegisterObservers and call tracker->AddObserver. This
19 // will attach the observer to all main frame navigations. 20 // will attach the observer to all main frame navigations.
20 class PageLoadMetricsObserverTestHarness 21 class PageLoadMetricsObserverTestHarness
21 : public ChromeRenderViewHostTestHarness { 22 : public ChromeRenderViewHostTestHarness {
22 public: 23 public:
23 PageLoadMetricsObserverTestHarness(); 24 PageLoadMetricsObserverTestHarness();
24 ~PageLoadMetricsObserverTestHarness() override; 25 ~PageLoadMetricsObserverTestHarness() override;
25 26
26 // Helper that fills in any timing fields that MWCO requires but that are 27 // Helper that fills in any timing fields that MWCO requires but that are
27 // currently missing. 28 // currently missing.
28 static void PopulateRequiredTimingFields(PageLoadTiming* inout_timing); 29 static void PopulateRequiredTimingFields(PageLoadTiming* inout_timing);
29 30
30 void SetUp() override; 31 void SetUp() override;
31 32
32 virtual void RegisterObservers(PageLoadTracker* tracker) {} 33 virtual void RegisterObservers(PageLoadTracker* tracker) {}
33 34
34 // Simulates starting a navigation to the given gurl, without committing the 35 // Simulates starting a navigation to the given gurl, without committing the
35 // navigation. 36 // navigation.
36 void StartNavigation(const GURL& gurl); 37 void StartNavigation(const GURL& gurl);
37 38
39 // Simulates committing a navigation to the given URL with the given
40 // PageTransition.
41 void NavigateWithPageTransitionAndCommit(const GURL& url,
42 ui::PageTransition transition);
43
38 // Call this to simulate sending a PageLoadTiming IPC from the render process 44 // Call this to simulate sending a PageLoadTiming IPC from the render process
39 // to the browser process. These will update the timing information for the 45 // to the browser process. These will update the timing information for the
40 // most recently committed navigation. 46 // most recently committed navigation.
41 void SimulateTimingUpdate(const PageLoadTiming& timing); 47 void SimulateTimingUpdate(const PageLoadTiming& timing);
42 void SimulateTimingAndMetadataUpdate(const PageLoadTiming& timing, 48 void SimulateTimingAndMetadataUpdate(const PageLoadTiming& timing,
43 const PageLoadMetadata& metadata); 49 const PageLoadMetadata& metadata);
44 50
45 // Simulates a user input. 51 // Simulates a user input.
46 void SimulateInputEvent(const blink::WebInputEvent& event); 52 void SimulateInputEvent(const blink::WebInputEvent& event);
47 53
48 const base::HistogramTester& histogram_tester() const; 54 const base::HistogramTester& histogram_tester() const;
49 55
50 // Gets the PageLoadExtraInfo for the committed_load_ in observer_. 56 // Gets the PageLoadExtraInfo for the committed_load_ in observer_.
51 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad(); 57 const PageLoadExtraInfo GetPageLoadExtraInfoForCommittedLoad();
52 58
53 private: 59 private:
54 base::HistogramTester histogram_tester_; 60 base::HistogramTester histogram_tester_;
55 MetricsWebContentsObserver* observer_; 61 MetricsWebContentsObserver* observer_;
56 62
57 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsObserverTestHarness); 63 DISALLOW_COPY_AND_ASSIGN(PageLoadMetricsObserverTestHarness);
58 }; 64 };
59 65
60 } // namespace page_load_metrics 66 } // namespace page_load_metrics
61 67
62 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER _TEST_HARNESS_H_ 68 #endif // CHROME_BROWSER_PAGE_LOAD_METRICS_OBSERVERS_PAGE_LOAD_METRICS_OBSERVER _TEST_HARNESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698