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

Side by Side Diff: content/renderer/presentation/presentation_dispatcher_unittest.cc

Issue 2484273003: [Presentation API] (1-UA) fire PresentationConnection onterminate event if receiver page gets destr… (Closed)
Patch Set: rebase Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/public/test/test_browser_thread_bundle.h" 9 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "content/renderer/presentation/presentation_connection_proxy.h" 10 #include "content/renderer/presentation/presentation_connection_proxy.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 MOCK_CONST_METHOD0(close, void()); 113 MOCK_CONST_METHOD0(close, void());
114 }; 114 };
115 115
116 class TestPresentationReceiver : public blink::WebPresentationReceiver { 116 class TestPresentationReceiver : public blink::WebPresentationReceiver {
117 public: 117 public:
118 blink::WebPresentationConnection* onReceiverConnectionAvailable( 118 blink::WebPresentationConnection* onReceiverConnectionAvailable(
119 const blink::WebPresentationSessionInfo&) override { 119 const blink::WebPresentationSessionInfo&) override {
120 return &connection_; 120 return &connection_;
121 } 121 }
122 122
123 MOCK_METHOD1(didChangeSessionState,
124 void(blink::WebPresentationConnectionState));
125 MOCK_METHOD0(terminateConnection, void());
126
123 TestPresentationConnection connection_; 127 TestPresentationConnection connection_;
124 }; 128 };
125 129
126 class MockPresentationAvailabilityCallbacks 130 class MockPresentationAvailabilityCallbacks
127 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> { 131 : public blink::WebCallbacks<bool, const blink::WebPresentationError&> {
128 public: 132 public:
129 MOCK_METHOD1(onSuccess, void(bool value)); 133 MOCK_METHOD1(onSuccess, void(bool value));
130 MOCK_METHOD1(onError, void(const blink::WebPresentationError&)); 134 MOCK_METHOD1(onError, void(const blink::WebPresentationError&));
131 }; 135 };
132 136
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 EXPECT_CALL(presentation_service_, 503 EXPECT_CALL(presentation_service_,
500 CloseConnection(gurl1_, presentation_id_.utf8())); 504 CloseConnection(gurl1_, presentation_id_.utf8()));
501 dispatcher_.closeSession(url1_, presentation_id_, &test_proxy); 505 dispatcher_.closeSession(url1_, presentation_id_, &test_proxy);
502 run_loop.RunUntilIdle(); 506 run_loop.RunUntilIdle();
503 } 507 }
504 508
505 TEST_F(PresentationDispatcherTest, TestTerminateSession) { 509 TEST_F(PresentationDispatcherTest, TestTerminateSession) {
506 base::RunLoop run_loop; 510 base::RunLoop run_loop;
507 EXPECT_CALL(presentation_service_, 511 EXPECT_CALL(presentation_service_,
508 Terminate(gurl1_, presentation_id_.utf8())); 512 Terminate(gurl1_, presentation_id_.utf8()));
509 dispatcher_.terminateSession(url1_, presentation_id_); 513 dispatcher_.terminateConnection(url1_, presentation_id_);
510 run_loop.RunUntilIdle(); 514 run_loop.RunUntilIdle();
511 } 515 }
512 516
513 TEST_F(PresentationDispatcherTest, TestListenForScreenAvailability) { 517 TEST_F(PresentationDispatcherTest, TestListenForScreenAvailability) {
514 base::RunLoop run_loop1; 518 base::RunLoop run_loop1;
515 for (const auto& gurl : gurls_) { 519 for (const auto& gurl : gurls_) {
516 EXPECT_CALL(presentation_service_, ListenForScreenAvailability(gurl)); 520 EXPECT_CALL(presentation_service_, ListenForScreenAvailability(gurl));
517 EXPECT_CALL(presentation_service_, 521 EXPECT_CALL(presentation_service_,
518 StopListeningForScreenAvailability(gurl)); 522 StopListeningForScreenAvailability(gurl));
519 } 523 }
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 777
774 for (auto* mock_observer : mock_observers_) 778 for (auto* mock_observer : mock_observers_)
775 EXPECT_CALL(*mock_observer, availabilityChanged(false)); 779 EXPECT_CALL(*mock_observer, availabilityChanged(false));
776 780
777 base::RunLoop run_loop_2; 781 base::RunLoop run_loop_2;
778 ChangeURLState(gurl2_, URLState::Unavailable); 782 ChangeURLState(gurl2_, URLState::Unavailable);
779 run_loop_2.RunUntilIdle(); 783 run_loop_2.RunUntilIdle();
780 } 784 }
781 785
782 } // namespace content 786 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698