Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp |
| diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9c8f1cd08f9c91dc3f333e1880ceeab4173d2efc |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/html/HTMLMediaElementTest.cpp |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/html/HTMLMediaElement.h" |
| + |
| +#include "core/dom/Document.h" |
| +#include "core/html/HTMLVideoElement.h" |
| +#include "core/loader/EmptyClients.h" |
| +#include "core/testing/DummyPageHolder.h" |
| +#include "platform/testing/UnitTestHelpers.h" |
| +#include "public/platform/WebMediaPlayer.h" |
| +#include "public/platform/WebSize.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace blink { |
| + |
| +class HTMLMediaElementTest : public ::testing::Test { |
| +protected: |
| + HTMLMediaElementTest() |
| + : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, EmptyFrameLoaderClient::create())) |
| + { |
| + m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); |
| + } |
| + |
| + void breakReadyState() |
| + { |
| + // Manually setup a situation when ready state goes out of sync with |
| + // m_webMediaPlayer. The real call sequence that results in error is unkown. |
| + m_video->setPreload("none"); |
| + m_video->setSrc("http://foo.bar/"); |
| + testing::runPendingTasks(); |
| + m_video->setReadyState(HTMLMediaElement::HAVE_FUTURE_DATA); |
| + m_video->remoteRouteAvailabilityChanged(true); |
|
mlamouri (slow - plz ping)
2016/05/19 13:13:03
Do you really need this line?
|
| + } |
| + |
| + OwnPtr<DummyPageHolder> m_dummyPageHolder; |
| + Persistent<HTMLVideoElement> m_video; |
| +}; |
| + |
| +TEST_F(HTMLMediaElementTest, webMediaPlayerOutOfSyncWithReadyState) |
| +{ |
| + breakReadyState(); |
| + |
| + WebMediaPlayer* player = m_video->webMediaPlayer(); |
| + ASSERT_FALSE(player); |
| + |
| + // Call setCurrentTime that accesses m_webMediaPlayer |
| + // If a check of m_webMediaPlayer for nullptr is missing, |
| + // the test crashes. |
| + m_video->setCurrentTime(0.0); |
| +} |
| + |
| +} // namespace blink |