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/Performance.h" | 5 #include "core/timing/Performance.h" |
6 | 6 |
| 7 #include "bindings/core/v8/PerformanceObserverCallback.h" |
7 #include "bindings/core/v8/V8BindingForTesting.h" | 8 #include "bindings/core/v8/V8BindingForTesting.h" |
8 #include "bindings/core/v8/V8PerformanceObserverCallback.h" | |
9 #include "core/timing/PerformanceBase.h" | 9 #include "core/timing/PerformanceBase.h" |
10 #include "core/timing/PerformanceLongTaskTiming.h" | 10 #include "core/timing/PerformanceLongTaskTiming.h" |
11 #include "core/timing/PerformanceObserver.h" | 11 #include "core/timing/PerformanceObserver.h" |
12 #include "core/timing/PerformanceObserverInit.h" | 12 #include "core/timing/PerformanceObserverInit.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 class TestPerformanceBase : public PerformanceBase { | 17 class TestPerformanceBase : public PerformanceBase { |
18 public: | 18 public: |
(...skipping 16 matching lines...) Expand all Loading... |
35 PerformanceBase::trace(visitor); | 35 PerformanceBase::trace(visitor); |
36 } | 36 } |
37 }; | 37 }; |
38 | 38 |
39 class PerformanceBaseTest : public ::testing::Test { | 39 class PerformanceBaseTest : public ::testing::Test { |
40 protected: | 40 protected: |
41 void initialize(ScriptState* scriptState) | 41 void initialize(ScriptState* scriptState) |
42 { | 42 { |
43 v8::Local<v8::Function> callback = v8::Function::New(scriptState->contex
t(), nullptr).ToLocalChecked(); | 43 v8::Local<v8::Function> callback = v8::Function::New(scriptState->contex
t(), nullptr).ToLocalChecked(); |
44 m_base = new TestPerformanceBase(); | 44 m_base = new TestPerformanceBase(); |
45 m_cb = V8PerformanceObserverCallback::create(scriptState->isolate(), cal
lback); | 45 m_cb = PerformanceObserverCallback::create(scriptState->isolate(), callb
ack); |
46 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); | 46 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); |
47 } | 47 } |
48 | 48 |
49 Persistent<TestPerformanceBase> m_base; | 49 Persistent<TestPerformanceBase> m_base; |
50 Persistent<PerformanceObserver> m_observer; | 50 Persistent<PerformanceObserver> m_observer; |
51 Persistent<V8PerformanceObserverCallback> m_cb; | 51 Persistent<PerformanceObserverCallback> m_cb; |
52 }; | 52 }; |
53 | 53 |
54 TEST_F(PerformanceBaseTest, Register) | 54 TEST_F(PerformanceBaseTest, Register) |
55 { | 55 { |
56 V8TestingScope scope; | 56 V8TestingScope scope; |
57 initialize(scope.getScriptState()); | 57 initialize(scope.getScriptState()); |
58 | 58 |
59 EXPECT_EQ(0, m_base->numObservers()); | 59 EXPECT_EQ(0, m_base->numObservers()); |
60 EXPECT_EQ(0, m_base->numActiveObservers()); | 60 EXPECT_EQ(0, m_base->numActiveObservers()); |
61 | 61 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 entryTypeVec.append("longtask"); | 105 entryTypeVec.append("longtask"); |
106 options.setEntryTypes(entryTypeVec); | 106 options.setEntryTypes(entryTypeVec); |
107 m_observer->observe(options, exceptionState); | 107 m_observer->observe(options, exceptionState); |
108 | 108 |
109 // Add a long task entry | 109 // Add a long task entry |
110 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar"); | 110 m_base->addLongTaskTiming(1234, 5678, "www.foo.com/bar"); |
111 EXPECT_EQ(1, m_base->numLongTaskTimingEntries()); // added an entry | 111 EXPECT_EQ(1, m_base->numLongTaskTimingEntries()); // added an entry |
112 } | 112 } |
113 | 113 |
114 } // namespace blink | 114 } // namespace blink |
OLD | NEW |