| 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/dom/TaskRunnerHelper.h" | 9 #include "core/dom/TaskRunnerHelper.h" |
| 10 #include "core/timing/Performance.h" | 10 #include "core/timing/Performance.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 ExecutionContext* getExecutionContext() const override { return nullptr; } | 27 ExecutionContext* getExecutionContext() const override { return nullptr; } |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 class PerformanceObserverTest : public ::testing::Test { | 30 class PerformanceObserverTest : public ::testing::Test { |
| 31 protected: | 31 protected: |
| 32 void initialize(ScriptState* scriptState) { | 32 void initialize(ScriptState* scriptState) { |
| 33 v8::Local<v8::Function> callback = | 33 v8::Local<v8::Function> callback = |
| 34 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); | 34 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); |
| 35 m_base = new MockPerformanceBase(scriptState); | 35 m_base = new MockPerformanceBase(scriptState); |
| 36 m_cb = PerformanceObserverCallback::create(scriptState, callback); | 36 m_cb = PerformanceObserverCallback::Create(scriptState, callback); |
| 37 m_observer = PerformanceObserver::create(scriptState->getExecutionContext(), | 37 m_observer = PerformanceObserver::create(scriptState->getExecutionContext(), |
| 38 m_base, m_cb); | 38 m_base, m_cb); |
| 39 } | 39 } |
| 40 | 40 |
| 41 bool isRegistered() { return m_observer->m_isRegistered; } | 41 bool isRegistered() { return m_observer->m_isRegistered; } |
| 42 int numPerformanceEntries() { | 42 int numPerformanceEntries() { |
| 43 return m_observer->m_performanceEntries.size(); | 43 return m_observer->m_performanceEntries.size(); |
| 44 } | 44 } |
| 45 void deliver() { m_observer->deliver(); } | 45 void deliver() { m_observer->deliver(); } |
| 46 | 46 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 EXPECT_EQ(0, numPerformanceEntries()); | 96 EXPECT_EQ(0, numPerformanceEntries()); |
| 97 | 97 |
| 98 m_observer->enqueuePerformanceEntry(*entry); | 98 m_observer->enqueuePerformanceEntry(*entry); |
| 99 EXPECT_EQ(1, numPerformanceEntries()); | 99 EXPECT_EQ(1, numPerformanceEntries()); |
| 100 | 100 |
| 101 m_observer->disconnect(); | 101 m_observer->disconnect(); |
| 102 EXPECT_FALSE(isRegistered()); | 102 EXPECT_FALSE(isRegistered()); |
| 103 EXPECT_EQ(0, numPerformanceEntries()); | 103 EXPECT_EQ(0, numPerformanceEntries()); |
| 104 } | 104 } |
| 105 } | 105 } |
| OLD | NEW |