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

Side by Side Diff: ios/chrome/browser/tabs/tab_unittest.mm

Issue 2860573003: Disables Native App Launcher functionality. (Closed)
Patch Set: fixed egtests compilation Created 3 years, 7 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/ios/block_types.h" 11 #include "base/ios/block_types.h"
12 #import "base/ios/weak_nsobject.h" 12 #import "base/ios/weak_nsobject.h"
13 #include "base/mac/scoped_nsobject.h" 13 #include "base/mac/scoped_nsobject.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/sys_string_conversions.h" 18 #include "base/strings/sys_string_conversions.h"
19 #include "components/bookmarks/test/bookmark_test_helpers.h" 19 #include "components/bookmarks/test/bookmark_test_helpers.h"
20 #include "components/history/core/browser/history_service.h" 20 #include "components/history/core/browser/history_service.h"
21 #include "components/keyed_service/core/service_access_type.h" 21 #include "components/keyed_service/core/service_access_type.h"
22 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" 22 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" 23 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
24 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h" 24 #include "ios/chrome/browser/browser_state/test_chrome_browser_state_manager.h"
25 #import "ios/chrome/browser/chrome_url_util.h" 25 #import "ios/chrome/browser/chrome_url_util.h"
26 #include "ios/chrome/browser/experimental_flags.h"
26 #include "ios/chrome/browser/history/history_service_factory.h" 27 #include "ios/chrome/browser/history/history_service_factory.h"
27 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" 28 #import "ios/chrome/browser/tabs/legacy_tab_helper.h"
28 #import "ios/chrome/browser/tabs/tab.h" 29 #import "ios/chrome/browser/tabs/tab.h"
29 #import "ios/chrome/browser/tabs/tab_helper_util.h" 30 #import "ios/chrome/browser/tabs/tab_helper_util.h"
30 #import "ios/chrome/browser/tabs/tab_model.h" 31 #import "ios/chrome/browser/tabs/tab_model.h"
31 #import "ios/chrome/browser/tabs/tab_private.h" 32 #import "ios/chrome/browser/tabs/tab_private.h"
32 #import "ios/chrome/browser/ui/open_in_controller.h" 33 #import "ios/chrome/browser/ui/open_in_controller.h"
33 #import "ios/chrome/browser/ui/open_in_controller_testing.h" 34 #import "ios/chrome/browser/ui/open_in_controller_testing.h"
34 #import "ios/chrome/browser/web/external_app_launcher.h" 35 #import "ios/chrome/browser/web/external_app_launcher.h"
35 #include "ios/chrome/test/block_cleanup_test.h" 36 #include "ios/chrome/test/block_cleanup_test.h"
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 465
465 // A version of TabOpenAppTests customized to use the off-the-record browser 466 // A version of TabOpenAppTests customized to use the off-the-record browser
466 // state (instead of the non-incognito one). 467 // state (instead of the non-incognito one).
467 class TabOpenAppOffTheRecordTest : public TabOpenAppTest { 468 class TabOpenAppOffTheRecordTest : public TabOpenAppTest {
468 private: 469 private:
469 bool UseOffTheRecordBrowserState() const override { return true; } 470 bool UseOffTheRecordBrowserState() const override { return true; }
470 }; 471 };
471 472
472 // Tests the opening of matching native apps. 473 // Tests the opening of matching native apps.
473 TEST_F(TabOpenAppTest, testDummyURL) { 474 TEST_F(TabOpenAppTest, testDummyURL) {
475 // TODO(crbug/711511): Remove this test when Native App Launcher has been
476 // fully deprecated.
477 if (!experimental_flags::IsNativeAppLauncherEnabled())
478 return;
474 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord()); 479 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord());
475 480
476 GURL no_native_app_url("dummy string"); 481 GURL no_native_app_url("dummy string");
477 TestOpenNativeAppURL(no_native_app_url, NO, 0, NO); 482 TestOpenNativeAppURL(no_native_app_url, NO, 0, NO);
478 } 483 }
479 484
480 TEST_F(TabOpenAppTest, testURL) { 485 TEST_F(TabOpenAppTest, testURL) {
486 // TODO(crbug/711511): Remove this test when Native App Launcher has been
487 // fully deprecated.
488 if (!experimental_flags::IsNativeAppLauncherEnabled())
489 return;
490
481 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord()); 491 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord());
482 492
483 GURL testURL("http://www.youtube.com/"); 493 GURL testURL("http://www.youtube.com/");
484 // Fake metadata object to enable and disable autoopenlinks for testURL. 494 // Fake metadata object to enable and disable autoopenlinks for testURL.
485 base::scoped_nsobject<FakeNativeAppMetadata> metadata( 495 base::scoped_nsobject<FakeNativeAppMetadata> metadata(
486 [[FakeNativeAppMetadata alloc] init]); 496 [[FakeNativeAppMetadata alloc] init]);
487 IOSChromeScopedTestingChromeBrowserProvider provider( 497 IOSChromeScopedTestingChromeBrowserProvider provider(
488 base::MakeUnique<FakeChromeBrowserProvider>(metadata)); 498 base::MakeUnique<FakeChromeBrowserProvider>(metadata));
489 // Turn auto open on. 499 // Turn auto open on.
490 int expectedCallCount = 1; 500 int expectedCallCount = 1;
491 [metadata setShouldAutoOpenLinks:YES]; 501 [metadata setShouldAutoOpenLinks:YES];
492 TestOpenNativeAppURL(testURL, YES, expectedCallCount, YES); 502 TestOpenNativeAppURL(testURL, YES, expectedCallCount, YES);
493 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 503 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
494 504
495 // Turn auto open off. 505 // Turn auto open off.
496 expectedCallCount = 0; 506 expectedCallCount = 0;
497 [metadata setShouldAutoOpenLinks:NO]; 507 [metadata setShouldAutoOpenLinks:NO];
498 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 508 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
499 } 509 }
500 510
501 // TODO(crbug.com/330189): This test fails if Google Maps is installed (usually 511 // TODO(crbug.com/330189): This test fails if Google Maps is installed (usually
502 // on device). 512 // on device).
503 TEST_F(TabOpenAppTest, DISABLED_testResetShouldAutoOpenOnFailure) { 513 TEST_F(TabOpenAppTest, DISABLED_testResetShouldAutoOpenOnFailure) {
514 // TODO(crbug/711511): Remove this test when Native App Launcher has been
515 // fully deprecated.
516 if (!experimental_flags::IsNativeAppLauncherEnabled())
517 return;
518
504 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord()); 519 EXPECT_FALSE([tab_ browserState]->IsOffTheRecord());
505 520
506 // With a regular profile. 521 // With a regular profile.
507 GURL testURL("http://maps.google.com/"); 522 GURL testURL("http://maps.google.com/");
508 // Fake metadata object 523 // Fake metadata object
509 base::scoped_nsobject<FakeNativeAppMetadata> metadata( 524 base::scoped_nsobject<FakeNativeAppMetadata> metadata(
510 [[FakeNativeAppMetadata alloc] init]); 525 [[FakeNativeAppMetadata alloc] init]);
511 526
512 // Turn auto open on. 527 // Turn auto open on.
513 [metadata setShouldAutoOpenLinks:YES]; 528 [metadata setShouldAutoOpenLinks:YES];
514 int expectedCallCount = 2; 529 int expectedCallCount = 2;
515 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 530 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
516 EXPECT_FALSE([metadata shouldAutoOpenLinks]); 531 EXPECT_FALSE([metadata shouldAutoOpenLinks]);
517 } 532 }
518 533
519 // Tests the opening of matching native apps with off-the-record browser state. 534 // Tests the opening of matching native apps with off-the-record browser state.
520 TEST_F(TabOpenAppOffTheRecordTest, testDummyURL) { 535 TEST_F(TabOpenAppOffTheRecordTest, testDummyURL) {
536 // TODO(crbug/711511): Remove this test when Native App Launcher has been
537 // fully deprecated.
538 if (!experimental_flags::IsNativeAppLauncherEnabled())
539 return;
540
521 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord()); 541 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord());
522 542
523 GURL no_native_app_url("dummy string"); 543 GURL no_native_app_url("dummy string");
524 TestOpenNativeAppURL(no_native_app_url, NO, 0, NO); 544 TestOpenNativeAppURL(no_native_app_url, NO, 0, NO);
525 } 545 }
526 546
527 TEST_F(TabOpenAppOffTheRecordTest, testURL) { 547 TEST_F(TabOpenAppOffTheRecordTest, testURL) {
548 // TODO(crbug/711511): Remove this test when Native App Launcher has been
549 // fully deprecated.
550 if (!experimental_flags::IsNativeAppLauncherEnabled())
551 return;
552
528 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord()); 553 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord());
529 554
530 // With a regular chrome browser state. 555 // With a regular chrome browser state.
531 GURL testURL("http://www.youtube.com/"); 556 GURL testURL("http://www.youtube.com/");
532 // Mock metadata object to enable and disable autoopenlinks for testURL. 557 // Mock metadata object to enable and disable autoopenlinks for testURL.
533 base::scoped_nsobject<FakeNativeAppMetadata> metadata( 558 base::scoped_nsobject<FakeNativeAppMetadata> metadata(
534 [[FakeNativeAppMetadata alloc] init]); 559 [[FakeNativeAppMetadata alloc] init]);
535 IOSChromeScopedTestingChromeBrowserProvider provider( 560 IOSChromeScopedTestingChromeBrowserProvider provider(
536 base::MakeUnique<FakeChromeBrowserProvider>(metadata)); 561 base::MakeUnique<FakeChromeBrowserProvider>(metadata));
537 562
538 // Turn auto open on. 563 // Turn auto open on.
539 [metadata setShouldAutoOpenLinks:YES]; 564 [metadata setShouldAutoOpenLinks:YES];
540 TestOpenNativeAppURL(testURL, NO, 0, NO); 565 TestOpenNativeAppURL(testURL, NO, 0, NO);
541 566
542 // Turn auto open off. 567 // Turn auto open off.
543 [metadata setShouldAutoOpenLinks:NO]; 568 [metadata setShouldAutoOpenLinks:NO];
544 TestOpenNativeAppURL(testURL, NO, 0, NO); 569 TestOpenNativeAppURL(testURL, NO, 0, NO);
545 } 570 }
546 571
547 // TODO(crbug.com/330189): This test fails if Google Maps is installed (usually 572 // TODO(crbug.com/330189): This test fails if Google Maps is installed (usually
548 // on device). 573 // on device).
549 TEST_F(TabOpenAppOffTheRecordTest, DISABLED_testResetShouldAutoOpenOnFailure) { 574 TEST_F(TabOpenAppOffTheRecordTest, DISABLED_testResetShouldAutoOpenOnFailure) {
575 // TODO(crbug/711511): Remove this test when Native App Launcher has been
576 // fully deprecated.
577 if (!experimental_flags::IsNativeAppLauncherEnabled())
578 return;
579
550 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord()); 580 EXPECT_TRUE([tab_ browserState]->IsOffTheRecord());
551 581
552 // With a regular profile. 582 // With a regular profile.
553 GURL testURL("http://maps.google.com/"); 583 GURL testURL("http://maps.google.com/");
554 // Fake metadata object. 584 // Fake metadata object.
555 base::scoped_nsobject<FakeNativeAppMetadata> metadata( 585 base::scoped_nsobject<FakeNativeAppMetadata> metadata(
556 [[FakeNativeAppMetadata alloc] init]); 586 [[FakeNativeAppMetadata alloc] init]);
557 587
558 // Turn auto open on. 588 // Turn auto open on.
559 [metadata setShouldAutoOpenLinks:YES]; 589 [metadata setShouldAutoOpenLinks:YES];
560 int expectedCallCount = 2; 590 int expectedCallCount = 2;
561 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); 591 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO);
562 EXPECT_FALSE([metadata shouldAutoOpenLinks]); 592 EXPECT_FALSE([metadata shouldAutoOpenLinks]);
563 } 593 }
564 594
565 } // namespace 595 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/chrome/browser/ui/settings/settings_collection_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698