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

Unified Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: rebase Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
diff --git a/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc b/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
index d8bb1ff72288dcc8f37f49eb795b6d9c510bce5a..2a607b576c78dce58015a75b50f0156d871a580c 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
+++ b/chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc
@@ -10,6 +10,8 @@
#include "chrome/browser/media/router/media_source_helper.h"
#include "chrome/browser/media/router/mock_media_router.h"
#include "chrome/browser/media/router/mock_screen_availability_listener.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
#include "chrome/browser/media/router/route_request_result.h"
#include "chrome/browser/media/router/test_helper.h"
#include "chrome/browser/profiles/profile.h"
@@ -20,6 +22,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/web_contents_tester.h"
+#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gmock/include/gmock/gmock.h"
using ::testing::_;
@@ -39,7 +42,7 @@ const char kFrameUrl[] = "http://anotherframeurl.fakeurl.com/";
namespace media_router {
class MockDelegateObserver
- : public content::PresentationServiceDelegate::Observer {
+ : public content::PresentationServiceDelegateBase::Observer {
public:
MOCK_METHOD0(OnDelegateDestroyed, void());
MOCK_METHOD1(OnDefaultPresentationStarted,
@@ -62,6 +65,38 @@ class MockCreatePresentationConnnectionCallbacks {
void(const content::PresentationError& error));
};
+class MockOffscreenPresentationManager : public OffscreenPresentationManager {
+ public:
+ void RegisterOffscreenPresentationController(
+ const std::string& presentation_id,
+ const GURL& presentation_url,
+ const RenderFrameHostId& render_frame_id,
+ content::PresentationConnectionPtr controller) override {
+ RegisterOffscreenPresentationController(presentation_id, presentation_url,
+ render_frame_id);
+ }
+
+ MOCK_METHOD3(RegisterOffscreenPresentationController,
+ void(const std::string& presentation_id,
+ const GURL& presentation_url,
+ const RenderFrameHostId& render_frame_id));
+ MOCK_METHOD2(UnregisterOffscreenPresentationController,
+ void(const std::string& presentation_id,
+ const RenderFrameHostId& render_frame_id));
+ MOCK_METHOD3(OnOffscreenPresentationReceiverCreated,
+ void(const std::string& presentation_id,
+ const GURL& presentation_url,
+ const content::ReceiverConnectionAvailableCallback&
+ receiver_callback));
+ MOCK_METHOD1(OnOffscreenPresentationReceiverTerminated,
+ void(const std::string& presentation_id));
+};
+
+std::unique_ptr<KeyedService> BuildMockOffscreenPresentationManager(
+ content::BrowserContext* context) {
+ return base::MakeUnique<MockOffscreenPresentationManager>();
+}
+
class PresentationServiceDelegateImplTest
: public ChromeRenderViewHostTestHarness {
public:
@@ -471,4 +506,28 @@ TEST_F(PresentationServiceDelegateImplTest, SinksObserverCantRegister) {
render_process_id, render_frame_id, &listener));
}
+TEST_F(PresentationServiceDelegateImplTest, ConnectToOffscreenPresentation) {
+ content::RenderFrameHost* main_frame = GetWebContents()->GetMainFrame();
+ ASSERT_TRUE(main_frame);
+ int render_process_id = main_frame->GetProcess()->GetID();
+ int render_frame_id = main_frame->GetRoutingID();
+ content::PresentationSessionInfo session_info(
+ GURL("http://www.example.com/presentation.html"), "presentation_id",
+ true);
+
+ OffscreenPresentationManagerFactory::GetInstance()->SetTestingFactory(
+ profile(), &BuildMockOffscreenPresentationManager);
+ MockOffscreenPresentationManager* mock_offscreen_manager =
+ static_cast<MockOffscreenPresentationManager*>(
+ OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
+ profile()));
+ EXPECT_CALL(*mock_offscreen_manager,
+ RegisterOffscreenPresentationController(_, _, _));
mark a. foltz 2016/11/15 23:41:46 Please validate arguments passed to RegisterOffscr
zhaobin 2016/11/16 18:02:41 Done.
+
+ content::PresentationConnectionPtr connection_ptr;
+ delegate_impl_->ConnectToOffscreenPresentation(render_process_id,
+ render_frame_id, session_info,
+ std::move(connection_ptr));
+}
+
} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698