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

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

Issue 2383613003: Remove 'V8' prefix from generated callback function classes (Closed)
Patch Set: Created 4 years, 2 months 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/PerformanceObserver.h" 5 #include "core/timing/PerformanceObserver.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/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 "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 MockPerformanceBase : public PerformanceBase { 17 class MockPerformanceBase : public PerformanceBase {
18 public: 18 public:
19 MockPerformanceBase() 19 MockPerformanceBase()
20 : PerformanceBase(0) 20 : PerformanceBase(0)
21 { 21 {
22 } 22 }
23 ~MockPerformanceBase() {} 23 ~MockPerformanceBase() {}
24 24
25 ExecutionContext* getExecutionContext() const override { return nullptr; } 25 ExecutionContext* getExecutionContext() const override { return nullptr; }
26 }; 26 };
27 27
28 class PerformanceObserverTest : public ::testing::Test { 28 class PerformanceObserverTest : public ::testing::Test {
29 protected: 29 protected:
30 void initialize(ScriptState* scriptState) 30 void initialize(ScriptState* scriptState)
31 { 31 {
32 v8::Local<v8::Function> callback = v8::Function::New(scriptState->contex t(), nullptr).ToLocalChecked(); 32 v8::Local<v8::Function> callback = v8::Function::New(scriptState->contex t(), nullptr).ToLocalChecked();
33 m_base = new MockPerformanceBase(); 33 m_base = new MockPerformanceBase();
34 m_cb = V8PerformanceObserverCallback::create(scriptState->isolate(), cal lback); 34 m_cb = PerformanceObserverCallback::create(scriptState->isolate(), callb ack);
35 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb); 35 m_observer = PerformanceObserver::create(scriptState, m_base, m_cb);
36 } 36 }
37 37
38 bool isRegistered() 38 bool isRegistered()
39 { 39 {
40 return m_observer->m_isRegistered; 40 return m_observer->m_isRegistered;
41 } 41 }
42 int numPerformanceEntries() 42 int numPerformanceEntries()
43 { 43 {
44 return m_observer->m_performanceEntries.size(); 44 return m_observer->m_performanceEntries.size();
45 } 45 }
46 void deliver() 46 void deliver()
47 { 47 {
48 m_observer->deliver(); 48 m_observer->deliver();
49 } 49 }
50 50
51 Persistent<MockPerformanceBase> m_base; 51 Persistent<MockPerformanceBase> m_base;
52 Persistent<V8PerformanceObserverCallback> m_cb; 52 Persistent<PerformanceObserverCallback> m_cb;
53 Persistent<PerformanceObserver> m_observer; 53 Persistent<PerformanceObserver> m_observer;
54 }; 54 };
55 55
56 TEST_F(PerformanceObserverTest, Observe) 56 TEST_F(PerformanceObserverTest, Observe)
57 { 57 {
58 V8TestingScope scope; 58 V8TestingScope scope;
59 initialize(scope.getScriptState()); 59 initialize(scope.getScriptState());
60 60
61 NonThrowableExceptionState exceptionState; 61 NonThrowableExceptionState exceptionState;
62 PerformanceObserverInit options; 62 PerformanceObserverInit options;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 EXPECT_EQ(0, numPerformanceEntries()); 104 EXPECT_EQ(0, numPerformanceEntries());
105 105
106 m_observer->enqueuePerformanceEntry(*entry); 106 m_observer->enqueuePerformanceEntry(*entry);
107 EXPECT_EQ(1, numPerformanceEntries()); 107 EXPECT_EQ(1, numPerformanceEntries());
108 108
109 m_observer->disconnect(); 109 m_observer->disconnect();
110 EXPECT_FALSE(isRegistered()); 110 EXPECT_FALSE(isRegistered());
111 EXPECT_EQ(0, numPerformanceEntries()); 111 EXPECT_EQ(0, numPerformanceEntries());
112 } 112 }
113 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698