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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceTest.cpp

Issue 2449673002: Refactor InspectorWebPerfAgent: update lifecycle management to be per Local Frame root; replace hea… (Closed)
Patch Set: sync and rebase Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "core/timing/Performance.h" 5 #include "core/timing/Performance.h"
6 6
7 #include "core/testing/DummyPageHolder.h" 7 #include "core/testing/DummyPageHolder.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class PerformanceTest : public ::testing::Test { 12 class PerformanceTest : public ::testing::Test {
13 protected: 13 protected:
14 void SetUp() override { 14 void SetUp() override {
15 m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); 15 m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
16 m_pageHolder->document().setURL(KURL(KURL(), "https://example.com")); 16 m_pageHolder->document().setURL(KURL(KURL(), "https://example.com"));
17 m_performance = Performance::create(&m_pageHolder->frame()); 17 m_performance = Performance::create(&m_pageHolder->frame());
18 } 18 }
19 19
20 bool hasLongTaskInspectorAgent() { 20 bool observingLongTasks() { return m_performance->observingLongTasks(); }
21 return m_performance->m_longTaskInspectorAgent;
22 }
23 21
24 void addLongTaskObserver() { 22 void addLongTaskObserver() {
25 // simulate with filter options. 23 // simulate with filter options.
26 m_performance->m_observerFilterOptions |= PerformanceEntry::LongTask; 24 m_performance->m_observerFilterOptions |= PerformanceEntry::LongTask;
27 } 25 }
28 26
29 void removeLongTaskObserver() { 27 void removeLongTaskObserver() {
30 // simulate with filter options. 28 // simulate with filter options.
31 m_performance->m_observerFilterOptions = PerformanceEntry::Invalid; 29 m_performance->m_observerFilterOptions = PerformanceEntry::Invalid;
32 } 30 }
33 31
34 Persistent<Performance> m_performance; 32 Persistent<Performance> m_performance;
35 std::unique_ptr<DummyPageHolder> m_pageHolder; 33 std::unique_ptr<DummyPageHolder> m_pageHolder;
36 }; 34 };
37 35
38 TEST_F(PerformanceTest, LongTaskObserverInstrumentation) { 36 TEST_F(PerformanceTest, LongTaskObserverInstrumentation) {
39 m_performance->updateLongTaskInstrumentation(); 37 m_performance->updateLongTaskInstrumentation();
40 EXPECT_FALSE(hasLongTaskInspectorAgent()); 38 EXPECT_FALSE(observingLongTasks());
41 39
42 // Adding LongTask observer (with filer option) enables instrumentation. 40 // Adding LongTask observer (with filer option) enables instrumentation.
43 addLongTaskObserver(); 41 addLongTaskObserver();
44 m_performance->updateLongTaskInstrumentation(); 42 m_performance->updateLongTaskInstrumentation();
45 EXPECT_TRUE(hasLongTaskInspectorAgent()); 43 EXPECT_TRUE(observingLongTasks());
46
47 // While LongTask observer is present, updateLongTaskInstrumentation has no
48 // effect.
49 m_performance->updateLongTaskInstrumentation();
50 EXPECT_TRUE(hasLongTaskInspectorAgent());
51 44
52 // Removing LongTask observer disables instrumentation. 45 // Removing LongTask observer disables instrumentation.
53 removeLongTaskObserver(); 46 removeLongTaskObserver();
54 m_performance->updateLongTaskInstrumentation(); 47 m_performance->updateLongTaskInstrumentation();
55 EXPECT_FALSE(hasLongTaskInspectorAgent()); 48 EXPECT_FALSE(observingLongTasks());
56 } 49 }
57 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698