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" |
11 #include "core/timing/PerformanceMark.h" | 11 #include "core/timing/PerformanceMark.h" |
12 #include "core/timing/PerformanceObserverInit.h" | 12 #include "core/timing/PerformanceObserverInit.h" |
13 #include "public/platform/Platform.h" | |
14 #include "public/platform/WebThread.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 namespace blink { | 17 namespace blink { |
16 | 18 |
17 class MockPerformanceBase : public PerformanceBase { | 19 class MockPerformanceBase : public PerformanceBase { |
18 public: | 20 public: |
19 MockPerformanceBase() : PerformanceBase(0) {} | 21 MockPerformanceBase() |
22 : PerformanceBase( | |
23 0, | |
24 Platform::current()->currentThread()->getWebTaskRunner()) {} | |
haraken
2017/01/20 02:30:25
Ditto.
| |
20 ~MockPerformanceBase() {} | 25 ~MockPerformanceBase() {} |
21 | 26 |
22 ExecutionContext* getExecutionContext() const override { return nullptr; } | 27 ExecutionContext* getExecutionContext() const override { return nullptr; } |
23 }; | 28 }; |
24 | 29 |
25 class PerformanceObserverTest : public ::testing::Test { | 30 class PerformanceObserverTest : public ::testing::Test { |
26 protected: | 31 protected: |
27 void initialize(ScriptState* scriptState) { | 32 void initialize(ScriptState* scriptState) { |
28 v8::Local<v8::Function> callback = | 33 v8::Local<v8::Function> callback = |
29 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); | 34 v8::Function::New(scriptState->context(), nullptr).ToLocalChecked(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 EXPECT_EQ(0, numPerformanceEntries()); | 96 EXPECT_EQ(0, numPerformanceEntries()); |
92 | 97 |
93 m_observer->enqueuePerformanceEntry(*entry); | 98 m_observer->enqueuePerformanceEntry(*entry); |
94 EXPECT_EQ(1, numPerformanceEntries()); | 99 EXPECT_EQ(1, numPerformanceEntries()); |
95 | 100 |
96 m_observer->disconnect(); | 101 m_observer->disconnect(); |
97 EXPECT_FALSE(isRegistered()); | 102 EXPECT_FALSE(isRegistered()); |
98 EXPECT_EQ(0, numPerformanceEntries()); | 103 EXPECT_EQ(0, numPerformanceEntries()); |
99 } | 104 } |
100 } | 105 } |
OLD | NEW |