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

Side by Side Diff: Source/core/dom/ActiveDOMObjectTest.cpp

Issue 765033003: Oilpan: Move MockActiveDOMObject to Oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
32 32
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/testing/DummyPageHolder.h" 34 #include "core/testing/DummyPageHolder.h"
35 #include <gmock/gmock.h> 35 #include <gmock/gmock.h>
36 #include <gtest/gtest.h> 36 #include <gtest/gtest.h>
37 37
38 using namespace blink; 38 using namespace blink;
39 39
40 namespace { 40 namespace {
41 41
42 class MockActiveDOMObject : public ActiveDOMObject { 42 class MockActiveDOMObject final : public GarbageCollectedFinalized<MockActiveDOM Object>, public ActiveDOMObject {
haraken 2014/12/03 02:19:44 At first, I wrote this as 'public GarbageCollected
tkent 2014/12/03 03:22:05 I guess the reason is that MockActiveDOMObject is
43 public: 43 public:
44 MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(context) { } 44 explicit MockActiveDOMObject(ExecutionContext* context) : ActiveDOMObject(co ntext) { }
45
46 void trace(Visitor*) { }
45 47
46 MOCK_METHOD0(suspend, void()); 48 MOCK_METHOD0(suspend, void());
47 MOCK_METHOD0(resume, void()); 49 MOCK_METHOD0(resume, void());
48 MOCK_METHOD0(stop, void()); 50 MOCK_METHOD0(stop, void());
49 }; 51 };
50 52
51 class ActiveDOMObjectTest : public ::testing::Test { 53 class ActiveDOMObjectTest : public ::testing::Test {
52 protected: 54 protected:
53 ActiveDOMObjectTest(); 55 ActiveDOMObjectTest();
54 56
55 Document& srcDocument() const { return m_srcPageHolder->document(); } 57 Document& srcDocument() const { return m_srcPageHolder->document(); }
56 Document& destDocument() const { return m_destPageHolder->document(); } 58 Document& destDocument() const { return m_destPageHolder->document(); }
57 MockActiveDOMObject& activeDOMObject() { return m_activeDOMObject; } 59 MockActiveDOMObject& activeDOMObject() { return *m_activeDOMObject; }
58 60
59 private: 61 private:
60 OwnPtr<DummyPageHolder> m_srcPageHolder; 62 OwnPtr<DummyPageHolder> m_srcPageHolder;
61 OwnPtr<DummyPageHolder> m_destPageHolder; 63 OwnPtr<DummyPageHolder> m_destPageHolder;
62 MockActiveDOMObject m_activeDOMObject; 64 Persistent<MockActiveDOMObject> m_activeDOMObject;
63 }; 65 };
64 66
65 ActiveDOMObjectTest::ActiveDOMObjectTest() 67 ActiveDOMObjectTest::ActiveDOMObjectTest()
66 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600))) 68 : m_srcPageHolder(DummyPageHolder::create(IntSize(800, 600)))
67 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600))) 69 , m_destPageHolder(DummyPageHolder::create(IntSize(800, 600)))
68 , m_activeDOMObject(&m_srcPageHolder->document()) 70 , m_activeDOMObject(new MockActiveDOMObject(&m_srcPageHolder->document()))
69 { 71 {
70 m_activeDOMObject.suspendIfNeeded(); 72 m_activeDOMObject->suspendIfNeeded();
71 } 73 }
72 74
73 TEST_F(ActiveDOMObjectTest, NewContextObserved) 75 TEST_F(ActiveDOMObjectTest, NewContextObserved)
74 { 76 {
75 unsigned initialSrcCount = srcDocument().activeDOMObjectCount(); 77 unsigned initialSrcCount = srcDocument().activeDOMObjectCount();
76 unsigned initialDestCount = destDocument().activeDOMObjectCount(); 78 unsigned initialDestCount = destDocument().activeDOMObjectCount();
77 79
78 EXPECT_CALL(activeDOMObject(), resume()); 80 EXPECT_CALL(activeDOMObject(), resume());
79 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 81 activeDOMObject().didMoveToNewExecutionContext(&destDocument());
80 82
(...skipping 17 matching lines...) Expand all
98 100
99 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument) 101 TEST_F(ActiveDOMObjectTest, MoveToStoppedDocument)
100 { 102 {
101 destDocument().detach(); 103 destDocument().detach();
102 104
103 EXPECT_CALL(activeDOMObject(), stop()); 105 EXPECT_CALL(activeDOMObject(), stop());
104 activeDOMObject().didMoveToNewExecutionContext(&destDocument()); 106 activeDOMObject().didMoveToNewExecutionContext(&destDocument());
105 } 107 }
106 108
107 } // unnamed namespace 109 } // unnamed namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698