| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/app/application_delegate/user_activity_handler.h" | 5 #include "ios/chrome/app/application_delegate/user_activity_handler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #import <CoreSpotlight/CoreSpotlight.h> | 9 #import <CoreSpotlight/CoreSpotlight.h> |
| 10 | 10 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 @[ | 409 @[ |
| 410 base::SysUTF8ToNSString(spotlight::kSpotlightActionVoiceSearch), @NO, | 410 base::SysUTF8ToNSString(spotlight::kSpotlightActionVoiceSearch), @NO, |
| 411 @YES, @NO | 411 @YES, @NO |
| 412 ], | 412 ], |
| 413 @[ | 413 @[ |
| 414 base::SysUTF8ToNSString(spotlight::kSpotlightActionQRScanner), @NO, @NO, | 414 base::SysUTF8ToNSString(spotlight::kSpotlightActionQRScanner), @NO, @NO, |
| 415 @YES | 415 @YES |
| 416 ] | 416 ] |
| 417 ]; | 417 ]; |
| 418 | 418 |
| 419 // Enable the QR Scanner and Spotlight Actions experiments. | 419 // Enable the Spotlight Actions experiment. |
| 420 base::test::ScopedCommandLine scoped_command_line; | 420 base::test::ScopedCommandLine scoped_command_line; |
| 421 scoped_command_line.GetProcessCommandLine()->AppendSwitch( | 421 scoped_command_line.GetProcessCommandLine()->AppendSwitch( |
| 422 switches::kEnableQRScanner); | |
| 423 scoped_command_line.GetProcessCommandLine()->AppendSwitch( | |
| 424 switches::kEnableSpotlightActions); | 422 switches::kEnableSpotlightActions); |
| 425 | 423 |
| 426 for (id parameters in parametersToTest) { | 424 for (id parameters in parametersToTest) { |
| 427 base::scoped_nsobject<NSUserActivity> userActivity([[NSUserActivity alloc] | 425 base::scoped_nsobject<NSUserActivity> userActivity([[NSUserActivity alloc] |
| 428 initWithActivityType:CSSearchableItemActionType]); | 426 initWithActivityType:CSSearchableItemActionType]); |
| 429 NSString* action = [NSString | 427 NSString* action = [NSString |
| 430 stringWithFormat:@"%@.%@", spotlight::StringFromSpotlightDomain( | 428 stringWithFormat:@"%@.%@", spotlight::StringFromSpotlightDomain( |
| 431 spotlight::DOMAIN_ACTIONS), | 429 spotlight::DOMAIN_ACTIONS), |
| 432 parameters[0]]; | 430 parameters[0]]; |
| 433 NSDictionary* userInfo = @{CSSearchableItemActivityIdentifier : action}; | 431 NSDictionary* userInfo = @{CSSearchableItemActivityIdentifier : action}; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 base::scoped_nsobject<FakeStartupInformation> fakeStartupInformation( | 541 base::scoped_nsobject<FakeStartupInformation> fakeStartupInformation( |
| 544 [[FakeStartupInformation alloc] init]); | 542 [[FakeStartupInformation alloc] init]); |
| 545 [fakeStartupInformation setIsPresentingFirstRunUI:NO]; | 543 [fakeStartupInformation setIsPresentingFirstRunUI:NO]; |
| 546 | 544 |
| 547 NSArray* parametersToTest = @[ | 545 NSArray* parametersToTest = @[ |
| 548 @[ @"OpenNewTab", @NO, @NO, @NO ], @[ @"OpenIncognitoTab", @YES, @NO, @NO ], | 546 @[ @"OpenNewTab", @NO, @NO, @NO ], @[ @"OpenIncognitoTab", @YES, @NO, @NO ], |
| 549 @[ @"OpenVoiceSearch", @NO, @YES, @NO ], | 547 @[ @"OpenVoiceSearch", @NO, @YES, @NO ], |
| 550 @[ @"OpenQRScanner", @NO, @NO, @YES ] | 548 @[ @"OpenQRScanner", @NO, @NO, @YES ] |
| 551 ]; | 549 ]; |
| 552 | 550 |
| 553 // Enable the QR Scanner experiment. | |
| 554 base::test::ScopedCommandLine scoped_command_line; | |
| 555 scoped_command_line.GetProcessCommandLine()->AppendSwitch( | |
| 556 switches::kEnableQRScanner); | |
| 557 | |
| 558 swizzleHandleStartupParameters(); | 551 swizzleHandleStartupParameters(); |
| 559 | 552 |
| 560 for (id parameters in parametersToTest) { | 553 for (id parameters in parametersToTest) { |
| 561 base::scoped_nsobject<UIApplicationShortcutItem> shortcut( | 554 base::scoped_nsobject<UIApplicationShortcutItem> shortcut( |
| 562 [[UIApplicationShortcutItem alloc] initWithType:parameters[0] | 555 [[UIApplicationShortcutItem alloc] initWithType:parameters[0] |
| 563 localizedTitle:parameters[0]]); | 556 localizedTitle:parameters[0]]); |
| 564 | 557 |
| 565 resetHandleStartupParametersHasBeenCalled(); | 558 resetHandleStartupParametersHasBeenCalled(); |
| 566 | 559 |
| 567 // The test will fail is a method of those objects is called. | 560 // The test will fail is a method of those objects is called. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 completionHandler:getCompletionHandler() | 609 completionHandler:getCompletionHandler() |
| 617 tabOpener:tabOpenerMock | 610 tabOpener:tabOpenerMock |
| 618 startupInformation:startupInformationMock | 611 startupInformation:startupInformationMock |
| 619 browserViewInformation:browserViewInformationMock]; | 612 browserViewInformation:browserViewInformationMock]; |
| 620 | 613 |
| 621 // Tests. | 614 // Tests. |
| 622 EXPECT_TRUE(completionHandlerExecuted()); | 615 EXPECT_TRUE(completionHandlerExecuted()); |
| 623 EXPECT_FALSE(completionHandlerArgument()); | 616 EXPECT_FALSE(completionHandlerArgument()); |
| 624 EXPECT_FALSE(getHandleStartupParametersHasBeenCalled()); | 617 EXPECT_FALSE(getHandleStartupParametersHasBeenCalled()); |
| 625 } | 618 } |
| OLD | NEW |