| Index: chrome/browser/media/webrtc_rtp_dump_handler_unittest.cc
|
| diff --git a/chrome/browser/media/webrtc_rtp_dump_handler_unittest.cc b/chrome/browser/media/webrtc_rtp_dump_handler_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1097b1a27b3b70790e36d8c4f35336ac45fac9cc
|
| --- /dev/null
|
| +++ b/chrome/browser/media/webrtc_rtp_dump_handler_unittest.cc
|
| @@ -0,0 +1,55 @@
|
| +// Copyright 2014 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 "base/bind.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/media/webrtc_rtp_dump_handler.h"
|
| +#include "content/public/test/test_browser_thread_bundle.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +class WebRtcRtpDumpHandlerTest : public testing::Test {
|
| + public:
|
| + WebRtcRtpDumpHandlerTest()
|
| + : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
|
| + handler_(new WebRtcRtpDumpHandler(base::FilePath())) {}
|
| +
|
| + MOCK_METHOD2(OnDumpReleased, void(bool, const base::FilePath&));
|
| +
|
| + protected:
|
| + content::TestBrowserThreadBundle thread_bundle_;
|
| + scoped_ptr<WebRtcRtpDumpHandler> handler_;
|
| +};
|
| +
|
| +TEST_F(WebRtcRtpDumpHandlerTest, StateTransition) {
|
| + WebRtcRtpDumpHandler::PacketType type_none = { false, false };
|
| + EXPECT_FALSE(handler_->StartDump(type_none));
|
| +
|
| + WebRtcRtpDumpHandler::PacketType types[3];
|
| + types[0] = { true, false };
|
| + types[1] = { false, true };
|
| + types[2] = { true, true };
|
| + for (size_t i = 0; i < arraysize(types); ++i) {
|
| + // Only StartDump is allowed in STATE_NONE.
|
| + EXPECT_FALSE(handler_->StopDump(types[i]));
|
| + EXPECT_FALSE(
|
| + handler_->ReleaseDump(WebRtcRtpDumpHandler::ReleaseDumpCallback()));
|
| + EXPECT_TRUE(handler_->StartDump(types[i]));
|
| +
|
| + // Only StopDump is allowed in STATE_STARTED.
|
| + EXPECT_FALSE(handler_->StartDump(types[i]));
|
| + EXPECT_FALSE(
|
| + handler_->ReleaseDump(WebRtcRtpDumpHandler::ReleaseDumpCallback()));
|
| + EXPECT_TRUE(handler_->StopDump(types[i]));
|
| +
|
| + // Only ReleaseDump is allowed in STATE_STOPPED.
|
| + EXPECT_FALSE(handler_->StartDump(types[i]));
|
| + EXPECT_FALSE(handler_->StopDump(types[i]));
|
| +
|
| + EXPECT_CALL(*this, OnDumpReleased(true, testing::_));
|
| + EXPECT_TRUE(handler_->ReleaseDump(base::Bind(
|
| + &WebRtcRtpDumpHandlerTest::OnDumpReleased, base::Unretained(this))));
|
| + }
|
| +}
|
|
|