Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/AutoplayUmaHelperTest.cpp |
| diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelperTest.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelperTest.cpp |
| index 77f75addd94e243a69901208bf53158b882779f4..43d43e2d790df7dee4cdf0eb0eb50434820d6dda 100644 |
| --- a/third_party/WebKit/Source/core/html/AutoplayUmaHelperTest.cpp |
| +++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelperTest.cpp |
| @@ -45,37 +45,35 @@ class AutoplayUmaHelperTest : public testing::Test { |
| return toHTMLVideoElement(*element); |
| } |
| - MockAutoplayUmaHelper& umaHelper() { |
| - return *(static_cast<MockAutoplayUmaHelper*>( |
| - mediaElement().m_autoplayUmaHelper.get())); |
| - } |
| + MockAutoplayUmaHelper& umaHelper() { return *m_umaHelper; } |
| std::unique_ptr<DummyPageHolder>& pageHolder() { return m_pageHolder; } |
| - MOCK_METHOD0(TestEnded, void()); |
| - |
| private: |
| void SetUp() override { |
| m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| document().documentElement()->setInnerHTML("<video id=video></video>", |
| ASSERT_NO_EXCEPTION); |
| HTMLMediaElement& element = mediaElement(); |
| - element.m_autoplayUmaHelper = new MockAutoplayUmaHelper(&element); |
| + m_umaHelper = new MockAutoplayUmaHelper(&element); |
| + element.m_autoplayUmaHelper = m_umaHelper; |
| + ::testing::Mock::AllowLeak(&element.m_autoplayUmaHelper); |
|
whywhat
2016/12/09 22:16:42
nit: you don't need this anymore - the object will
Zhiqiang Zhang (Slow)
2016/12/12 20:31:24
Done.
|
| } |
| + void TearDown() override { m_umaHelper.clear(); } |
| + |
| std::unique_ptr<DummyPageHolder> m_pageHolder; |
| + Persistent<MockAutoplayUmaHelper> m_umaHelper; |
| }; |
| TEST_F(AutoplayUmaHelperTest, VisibilityChangeWhenUnload) { |
| - // This is to avoid handleContextDestroyed() to be called during TearDown(). |
| - EXPECT_CALL(*this, TestEnded()) |
| - .After(EXPECT_CALL(umaHelper(), handleContextDestroyed())); |
| + EXPECT_CALL(umaHelper(), handleContextDestroyed()); |
| mediaElement().setMuted(true); |
| umaHelper().onAutoplayInitiated(AutoplaySource::Attribute); |
| umaHelper().handlePlayingEvent(); |
| pageHolder().reset(); |
| - TestEnded(); |
| + ::testing::Mock::VerifyAndClear(&umaHelper()); |
| } |
| } // namespace blink |