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

Side by Side Diff: third_party/WebKit/Source/core/dom/SuspendableObjectTest.cpp

Issue 2587913002: Rename activeDOMObjectsAreSuspended to isContextSuspended (Closed)
Patch Set: temp Created 3 years, 12 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 /* 1 /*
2 * Copyright (c) 2014, Google Inc. All rights reserved. 2 * Copyright (c) 2014, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 MOCK_METHOD0(resume, void()); 53 MOCK_METHOD0(resume, void());
54 MOCK_METHOD0(contextDestroyed, void()); 54 MOCK_METHOD0(contextDestroyed, void());
55 }; 55 };
56 56
57 class SuspendableObjectTest : public ::testing::Test { 57 class SuspendableObjectTest : public ::testing::Test {
58 protected: 58 protected:
59 SuspendableObjectTest(); 59 SuspendableObjectTest();
60 60
61 Document& srcDocument() const { return m_srcPageHolder->document(); } 61 Document& srcDocument() const { return m_srcPageHolder->document(); }
62 Document& destDocument() const { return m_destPageHolder->document(); } 62 Document& destDocument() const { return m_destPageHolder->document(); }
63 MockSuspendableObject& activeDOMObject() { return *m_activeDOMObject; } 63 MockSuspendableObject& suspendableObject() { return *m_suspendableObject; }
64 64
65 private: 65 private:
66 std::unique_ptr<DummyPageHolder> m_srcPageHolder; 66 std::unique_ptr<DummyPageHolder> m_srcPageHolder;
67 std::unique_ptr<DummyPageHolder> m_destPageHolder; 67 std::unique_ptr<DummyPageHolder> m_destPageHolder;
68 Persistent<MockSuspendableObject> m_activeDOMObject; 68 Persistent<MockSuspendableObject> m_suspendableObject;
69 }; 69 };
70 70
71 SuspendableObjectTest::SuspendableObjectTest() 71 SuspendableObjectTest::SuspendableObjectTest()
72 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))), 72 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))),
73 m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))), 73 m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))),
74 m_activeDOMObject( 74 m_suspendableObject(
75 new MockSuspendableObject(&m_srcPageHolder->document())) { 75 new MockSuspendableObject(&m_srcPageHolder->document())) {
76 m_activeDOMObject->suspendIfNeeded(); 76 m_suspendableObject->suspendIfNeeded();
77 } 77 }
78 78
79 TEST_F(SuspendableObjectTest, NewContextObserved) { 79 TEST_F(SuspendableObjectTest, NewContextObserved) {
80 unsigned initialSrcCount = srcDocument().activeDOMObjectCount(); 80 unsigned initialSrcCount = srcDocument().suspendableObjectCount();
81 unsigned initialDestCount = destDocument().activeDOMObjectCount(); 81 unsigned initialDestCount = destDocument().suspendableObjectCount();
82 82
83 EXPECT_CALL(activeDOMObject(), resume()); 83 EXPECT_CALL(suspendableObject(), resume());
84 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 84 suspendableObject().didMoveToNewExecutionContext(&destDocument());
85 85
86 EXPECT_EQ(initialSrcCount - 1, srcDocument().activeDOMObjectCount()); 86 EXPECT_EQ(initialSrcCount - 1, srcDocument().suspendableObjectCount());
87 EXPECT_EQ(initialDestCount + 1, destDocument().activeDOMObjectCount()); 87 EXPECT_EQ(initialDestCount + 1, destDocument().suspendableObjectCount());
88 } 88 }
89 89
90 TEST_F(SuspendableObjectTest, MoveToActiveDocument) { 90 TEST_F(SuspendableObjectTest, MoveToActiveDocument) {
91 EXPECT_CALL(activeDOMObject(), resume()); 91 EXPECT_CALL(suspendableObject(), resume());
92 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 92 suspendableObject().didMoveToNewExecutionContext(&destDocument());
93 } 93 }
94 94
95 TEST_F(SuspendableObjectTest, MoveToSuspendedDocument) { 95 TEST_F(SuspendableObjectTest, MoveToSuspendedDocument) {
96 destDocument().suspendScheduledTasks(); 96 destDocument().suspendScheduledTasks();
97 97
98 EXPECT_CALL(activeDOMObject(), suspend()); 98 EXPECT_CALL(suspendableObject(), suspend());
99 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 99 suspendableObject().didMoveToNewExecutionContext(&destDocument());
100 } 100 }
101 101
102 TEST_F(SuspendableObjectTest, MoveToStoppedDocument) { 102 TEST_F(SuspendableObjectTest, MoveToStoppedDocument) {
103 destDocument().shutdown(); 103 destDocument().shutdown();
104 104
105 EXPECT_CALL(activeDOMObject(), contextDestroyed()); 105 EXPECT_CALL(suspendableObject(), contextDestroyed());
106 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 106 suspendableObject().didMoveToNewExecutionContext(&destDocument());
107 } 107 }
108 108
109 } // namespace blink 109 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/SuspendableObject.cpp ('k') | third_party/WebKit/Source/core/frame/DOMTimer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698