OLD | NEW |
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/PerformanceObserver.h" | 5 #include "core/timing/PerformanceObserver.h" |
6 | 6 |
7 #include "bindings/core/v8/PerformanceObserverCallback.h" | 7 #include "bindings/core/v8/PerformanceObserverCallback.h" |
8 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
9 #include "core/timing/Performance.h" | 9 #include "core/timing/Performance.h" |
10 #include "core/timing/PerformanceBase.h" | 10 #include "core/timing/PerformanceBase.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 ExecutionContext* getExecutionContext() const override { return nullptr; } | 22 ExecutionContext* getExecutionContext() const override { return nullptr; } |
23 }; | 23 }; |
24 | 24 |
25 class PerformanceObserverTest : public ::testing::Test { | 25 class PerformanceObserverTest : public ::testing::Test { |
26 protected: | 26 protected: |
27 void initialize(ScriptState* scriptState) { | 27 void initialize(ScriptState* scriptState) { |
28 v8::Local<v8::Function> callback = | 28 v8::Local<v8::Function> callback = |
29 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); | 29 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); |
30 m_base = new MockPerformanceBase(); | 30 m_base = new MockPerformanceBase(); |
31 m_cb = PerformanceObserverCallback::create(scriptState, callback); | 31 m_cb = PerformanceObserverCallback::create(scriptState, callback); |
32 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); | 32 m_observer = PerformanceObserver::create(scriptState->getExecutionContext(), |
| 33 m_base, m_cb); |
33 } | 34 } |
34 | 35 |
35 bool isRegistered() { return m_observer->m_isRegistered; } | 36 bool isRegistered() { return m_observer->m_isRegistered; } |
36 int numPerformanceEntries() { | 37 int numPerformanceEntries() { |
37 return m_observer->m_performanceEntries.size(); | 38 return m_observer->m_performanceEntries.size(); |
38 } | 39 } |
39 void deliver() { m_observer->deliver(); } | 40 void deliver() { m_observer->deliver(); } |
40 | 41 |
41 Persistent<MockPerformanceBase> m_base; | 42 Persistent<MockPerformanceBase> m_base; |
42 Persistent<PerformanceObserverCallback> m_cb; | 43 Persistent<PerformanceObserverCallback> m_cb; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 EXPECT_EQ(0, numPerformanceEntries()); | 91 EXPECT_EQ(0, numPerformanceEntries()); |
91 | 92 |
92 m_observer->enqueuePerformanceEntry(*entry); | 93 m_observer->enqueuePerformanceEntry(*entry); |
93 EXPECT_EQ(1, numPerformanceEntries()); | 94 EXPECT_EQ(1, numPerformanceEntries()); |
94 | 95 |
95 m_observer->disconnect(); | 96 m_observer->disconnect(); |
96 EXPECT_FALSE(isRegistered()); | 97 EXPECT_FALSE(isRegistered()); |
97 EXPECT_EQ(0, numPerformanceEntries()); | 98 EXPECT_EQ(0, numPerformanceEntries()); |
98 } | 99 } |
99 } | 100 } |
OLD | NEW |