Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/html/HTMLMediaElement.h" | |
| 6 | |
| 7 #include "core/dom/Document.h" | |
| 8 #include "core/html/HTMLVideoElement.h" | |
| 9 #include "core/loader/EmptyClients.h" | |
| 10 #include "core/testing/DummyPageHolder.h" | |
| 11 #include "platform/testing/UnitTestHelpers.h" | |
| 12 #include "public/platform/WebMediaPlayer.h" | |
| 13 #include "public/platform/WebSize.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 class HTMLMediaElementTest : public ::testing::Test { | |
| 19 protected: | |
| 20 HTMLMediaElementTest() | |
| 21 : m_dummyPageHolder(DummyPageHolder::create(IntSize(640, 360), nullptr, EmptyFrameLoaderClient::create())) | |
| 22 { | |
| 23 m_video = HTMLVideoElement::create(m_dummyPageHolder->document()); | |
| 24 } | |
| 25 | |
| 26 void breakReadyState() | |
| 27 { | |
| 28 // Manually setup a situation when ready state goes out of sync with | |
| 29 // m_webMediaPlayer. The real call sequence that results in error is unk own. | |
| 30 m_video->setPreload("none"); | |
| 31 m_video->setSrc("http://foo.bar/"); | |
| 32 testing::runPendingTasks(); | |
| 33 m_video->setReadyState(HTMLMediaElement::HAVE_FUTURE_DATA); | |
| 34 m_video->remoteRouteAvailabilityChanged(true); | |
|
mlamouri (slow - plz ping)
2016/05/19 13:13:03
Do you really need this line?
| |
| 35 } | |
| 36 | |
| 37 OwnPtr<DummyPageHolder> m_dummyPageHolder; | |
| 38 Persistent<HTMLVideoElement> m_video; | |
| 39 }; | |
| 40 | |
| 41 TEST_F(HTMLMediaElementTest, webMediaPlayerOutOfSyncWithReadyState) | |
| 42 { | |
| 43 breakReadyState(); | |
| 44 | |
| 45 WebMediaPlayer* player = m_video->webMediaPlayer(); | |
| 46 ASSERT_FALSE(player); | |
| 47 | |
| 48 // Call setCurrentTime that accesses m_webMediaPlayer | |
| 49 // If a check of m_webMediaPlayer for nullptr is missing, | |
| 50 // the test crashes. | |
| 51 m_video->setCurrentTime(0.0); | |
| 52 } | |
| 53 | |
| 54 } // namespace blink | |
| OLD | NEW |