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

Side by Side Diff: chrome/browser/media/router/presentation_service_delegate_impl_unittest.cc

Issue 2664753002: Remove base::StringValue (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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/mock_callback.h" 8 #include "base/test/mock_callback.h"
9 #include "chrome/browser/media/router/media_source.h" 9 #include "chrome/browser/media/router/media_source.h"
10 #include "chrome/browser/media/router/media_source_helper.h" 10 #include "chrome/browser/media/router/media_source_helper.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 ->NavigateAndCommit(frame_url); 540 ->NavigateAndCommit(frame_url);
541 541
542 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; 542 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks;
543 const std::string kPresentationId("auto-join"); 543 const std::string kPresentationId("auto-join");
544 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId)); 544 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId));
545 545
546 // Set the user preference for |origin| to prefer tab mirroring. 546 // Set the user preference for |origin| to prefer tab mirroring.
547 { 547 {
548 ListPrefUpdate update(profile()->GetPrefs(), 548 ListPrefUpdate update(profile()->GetPrefs(),
549 prefs::kMediaRouterTabMirroringSources); 549 prefs::kMediaRouterTabMirroringSources);
550 update->AppendIfNotPresent(base::MakeUnique<base::StringValue>(origin)); 550 update->AppendIfNotPresent(base::MakeUnique<base::Value>(origin));
551 } 551 }
552 552
553 // Auto-join requests should be rejected. 553 // Auto-join requests should be rejected.
554 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionError(_)); 554 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionError(_));
555 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(0); 555 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(0);
556 delegate_impl_->JoinSession( 556 delegate_impl_->JoinSession(
557 main_frame_process_id_, main_frame_routing_id_, presentation_urls_, 557 main_frame_process_id_, main_frame_routing_id_, presentation_urls_,
558 kPresentationId, 558 kPresentationId,
559 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 559 base::Bind(&MockCreatePresentationConnnectionCallbacks::
560 OnCreateConnectionSuccess, 560 OnCreateConnectionSuccess,
561 base::Unretained(&mock_create_connection_callbacks)), 561 base::Unretained(&mock_create_connection_callbacks)),
562 base::Bind( 562 base::Bind(
563 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 563 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
564 base::Unretained(&mock_create_connection_callbacks))); 564 base::Unretained(&mock_create_connection_callbacks)));
565 565
566 // Remove the user preference for |origin|. 566 // Remove the user preference for |origin|.
567 { 567 {
568 ListPrefUpdate update(profile()->GetPrefs(), 568 ListPrefUpdate update(profile()->GetPrefs(),
569 prefs::kMediaRouterTabMirroringSources); 569 prefs::kMediaRouterTabMirroringSources);
570 update->Remove(base::StringValue(origin), nullptr); 570 update->Remove(base::Value(origin), nullptr);
571 } 571 }
572 572
573 // Auto-join requests should now go through. 573 // Auto-join requests should now go through.
574 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(1); 574 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(1);
575 delegate_impl_->JoinSession( 575 delegate_impl_->JoinSession(
576 main_frame_process_id_, main_frame_routing_id_, presentation_urls_, 576 main_frame_process_id_, main_frame_routing_id_, presentation_urls_,
577 kPresentationId, 577 kPresentationId,
578 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 578 base::Bind(&MockCreatePresentationConnnectionCallbacks::
579 OnCreateConnectionSuccess, 579 OnCreateConnectionSuccess,
580 base::Unretained(&mock_create_connection_callbacks)), 580 base::Unretained(&mock_create_connection_callbacks)),
581 base::Bind( 581 base::Bind(
582 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 582 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
583 base::Unretained(&mock_create_connection_callbacks))); 583 base::Unretained(&mock_create_connection_callbacks)));
584 } 584 }
585 585
586 TEST_F(PresentationServiceDelegateImplIncognitoTest, AutoJoinRequest) { 586 TEST_F(PresentationServiceDelegateImplIncognitoTest, AutoJoinRequest) {
587 GURL frame_url(kFrameUrl); 587 GURL frame_url(kFrameUrl);
588 std::string origin(url::Origin(frame_url).Serialize()); 588 std::string origin(url::Origin(frame_url).Serialize());
589 content::WebContentsTester::For(GetWebContents()) 589 content::WebContentsTester::For(GetWebContents())
590 ->NavigateAndCommit(frame_url); 590 ->NavigateAndCommit(frame_url);
591 591
592 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks; 592 MockCreatePresentationConnnectionCallbacks mock_create_connection_callbacks;
593 const std::string kPresentationId("auto-join"); 593 const std::string kPresentationId("auto-join");
594 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId)); 594 ASSERT_TRUE(IsAutoJoinPresentationId(kPresentationId));
595 595
596 // Set the user preference for |origin| to prefer tab mirroring. 596 // Set the user preference for |origin| to prefer tab mirroring.
597 { 597 {
598 ListPrefUpdate update(profile()->GetOffTheRecordProfile()->GetPrefs(), 598 ListPrefUpdate update(profile()->GetOffTheRecordProfile()->GetPrefs(),
599 prefs::kMediaRouterTabMirroringSources); 599 prefs::kMediaRouterTabMirroringSources);
600 update->AppendIfNotPresent(base::MakeUnique<base::StringValue>(origin)); 600 update->AppendIfNotPresent(base::MakeUnique<base::Value>(origin));
601 } 601 }
602 602
603 // Setting the pref in incognito shouldn't set it for the non-incognito 603 // Setting the pref in incognito shouldn't set it for the non-incognito
604 // profile. 604 // profile.
605 const base::ListValue* non_incognito_origins = 605 const base::ListValue* non_incognito_origins =
606 profile()->GetPrefs()->GetList(prefs::kMediaRouterTabMirroringSources); 606 profile()->GetPrefs()->GetList(prefs::kMediaRouterTabMirroringSources);
607 EXPECT_EQ(non_incognito_origins->Find(base::StringValue(origin)), 607 EXPECT_EQ(non_incognito_origins->Find(base::Value(origin)),
608 non_incognito_origins->end()); 608 non_incognito_origins->end());
609 609
610 // Auto-join requests should be rejected. 610 // Auto-join requests should be rejected.
611 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionError(_)); 611 EXPECT_CALL(mock_create_connection_callbacks, OnCreateConnectionError(_));
612 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(0); 612 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(0);
613 delegate_impl_->JoinSession( 613 delegate_impl_->JoinSession(
614 main_frame_process_id_, main_frame_routing_id_, presentation_urls_, 614 main_frame_process_id_, main_frame_routing_id_, presentation_urls_,
615 kPresentationId, 615 kPresentationId,
616 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 616 base::Bind(&MockCreatePresentationConnnectionCallbacks::
617 OnCreateConnectionSuccess, 617 OnCreateConnectionSuccess,
618 base::Unretained(&mock_create_connection_callbacks)), 618 base::Unretained(&mock_create_connection_callbacks)),
619 base::Bind( 619 base::Bind(
620 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 620 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
621 base::Unretained(&mock_create_connection_callbacks))); 621 base::Unretained(&mock_create_connection_callbacks)));
622 622
623 // Remove the user preference for |origin| in incognito. 623 // Remove the user preference for |origin| in incognito.
624 { 624 {
625 ListPrefUpdate update(profile()->GetOffTheRecordProfile()->GetPrefs(), 625 ListPrefUpdate update(profile()->GetOffTheRecordProfile()->GetPrefs(),
626 prefs::kMediaRouterTabMirroringSources); 626 prefs::kMediaRouterTabMirroringSources);
627 update->Remove(base::StringValue(origin), nullptr); 627 update->Remove(base::Value(origin), nullptr);
628 } 628 }
629 629
630 // Auto-join requests should now go through. 630 // Auto-join requests should now go through.
631 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(1); 631 EXPECT_CALL(router_, JoinRoute(_, kPresentationId, _, _, _, _, _)).Times(1);
632 delegate_impl_->JoinSession( 632 delegate_impl_->JoinSession(
633 main_frame_process_id_, main_frame_routing_id_, presentation_urls_, 633 main_frame_process_id_, main_frame_routing_id_, presentation_urls_,
634 kPresentationId, 634 kPresentationId,
635 base::Bind(&MockCreatePresentationConnnectionCallbacks:: 635 base::Bind(&MockCreatePresentationConnnectionCallbacks::
636 OnCreateConnectionSuccess, 636 OnCreateConnectionSuccess,
637 base::Unretained(&mock_create_connection_callbacks)), 637 base::Unretained(&mock_create_connection_callbacks)),
638 base::Bind( 638 base::Bind(
639 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError, 639 &MockCreatePresentationConnnectionCallbacks::OnCreateConnectionError,
640 base::Unretained(&mock_create_connection_callbacks))); 640 base::Unretained(&mock_create_connection_callbacks)));
641 } 641 }
642 #endif // !defined(OS_ANDROID) 642 #endif // !defined(OS_ANDROID)
643 643
644 } // namespace media_router 644 } // namespace media_router
OLDNEW
« no previous file with comments | « chrome/browser/media/router/presentation_service_delegate_impl.cc ('k') | chrome/browser/net/disk_cache_dir_policy_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698