Commit 1865bfc3 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Credential-Provider] Add UI tests in Showcase

Adds basic UI tests for the consent, empty credentials and stale
credentials screens.

Bug: 1045448, 1045452, 1045453
Change-Id: I1b103fb09f84ddc2c1b1e8dd27d718a92541d75e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2086232
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746720}
parent d785c1a6
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
// A11y Identifiers for testing.
extern NSString* const kConfirmationAlertMoreInfoAccessibilityIdentifier;
extern NSString* const kConfirmationAlertTitleAccessibilityIdentifier;
extern NSString* const kConfirmationAlertSubtitleAccessibilityIdentifier;
extern NSString* const kConfirmationAlertPrimaryActionAccessibilityIdentifier;
@protocol ConfirmationAlertActionHandler; @protocol ConfirmationAlertActionHandler;
// A view controller useful to show modal alerts and confirmations. The main // A view controller useful to show modal alerts and confirmations. The main
......
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kConfirmationAlertMoreInfoAccessibilityIdentifier =
@"kConfirmationAlertMoreInfoAccessibilityIdentifier";
NSString* const kConfirmationAlertTitleAccessibilityIdentifier =
@"kConfirmationAlertTitleAccessibilityIdentifier";
NSString* const kConfirmationAlertSubtitleAccessibilityIdentifier =
@"kConfirmationAlertSubtitleAccessibilityIdentifier";
NSString* const kConfirmationAlertPrimaryActionAccessibilityIdentifier =
@"kConfirmationAlertPrimaryActionAccessibilityIdentifier";
namespace { namespace {
constexpr CGFloat kButtonVerticalInsets = 17; constexpr CGFloat kButtonVerticalInsets = 17;
...@@ -251,6 +260,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8; ...@@ -251,6 +260,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8;
target:self target:self
action:@selector(didTapHelpButton)]; action:@selector(didTapHelpButton)];
[items addObject:helpButton]; [items addObject:helpButton];
helpButton.accessibilityIdentifier =
kConfirmationAlertMoreInfoAccessibilityIdentifier;
// Set the help button as the left button item so it can be used as a // Set the help button as the left button item so it can be used as a
// popover anchor. // popover anchor.
_helpButton = helpButton; _helpButton = helpButton;
...@@ -297,6 +308,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8; ...@@ -297,6 +308,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8;
title.textAlignment = NSTextAlignmentCenter; title.textAlignment = NSTextAlignmentCenter;
title.translatesAutoresizingMaskIntoConstraints = NO; title.translatesAutoresizingMaskIntoConstraints = NO;
title.adjustsFontForContentSizeCategory = YES; title.adjustsFontForContentSizeCategory = YES;
title.accessibilityIdentifier =
kConfirmationAlertTitleAccessibilityIdentifier;
return title; return title;
} }
...@@ -310,6 +323,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8; ...@@ -310,6 +323,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8;
subtitle.textAlignment = NSTextAlignmentCenter; subtitle.textAlignment = NSTextAlignmentCenter;
subtitle.translatesAutoresizingMaskIntoConstraints = NO; subtitle.translatesAutoresizingMaskIntoConstraints = NO;
subtitle.adjustsFontForContentSizeCategory = YES; subtitle.adjustsFontForContentSizeCategory = YES;
subtitle.accessibilityIdentifier =
kConfirmationAlertSubtitleAccessibilityIdentifier;
return subtitle; return subtitle;
} }
...@@ -354,6 +369,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8; ...@@ -354,6 +369,8 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8;
primaryActionButton.layer.cornerRadius = kPrimaryButtonCornerRadius; primaryActionButton.layer.cornerRadius = kPrimaryButtonCornerRadius;
primaryActionButton.titleLabel.adjustsFontForContentSizeCategory = NO; primaryActionButton.titleLabel.adjustsFontForContentSizeCategory = NO;
primaryActionButton.translatesAutoresizingMaskIntoConstraints = NO; primaryActionButton.translatesAutoresizingMaskIntoConstraints = NO;
primaryActionButton.accessibilityIdentifier =
kConfirmationAlertPrimaryActionAccessibilityIdentifier;
return primaryActionButton; return primaryActionButton;
} }
......
...@@ -26,6 +26,7 @@ group("features") { ...@@ -26,6 +26,7 @@ group("features") {
"//ios/showcase/badges", "//ios/showcase/badges",
"//ios/showcase/bubble", "//ios/showcase/bubble",
"//ios/showcase/content_suggestions", "//ios/showcase/content_suggestions",
"//ios/showcase/credential_provider",
"//ios/showcase/infobars", "//ios/showcase/infobars",
"//ios/showcase/omnibox_popup", "//ios/showcase/omnibox_popup",
"//ios/showcase/recent_tabs", "//ios/showcase/recent_tabs",
...@@ -73,6 +74,7 @@ ios_eg2_test("ios_showcase_eg2tests_module") { ...@@ -73,6 +74,7 @@ ios_eg2_test("ios_showcase_eg2tests_module") {
"//ios/showcase/bubble:eg2_tests", "//ios/showcase/bubble:eg2_tests",
"//ios/showcase/content_suggestions:eg2_tests", "//ios/showcase/content_suggestions:eg2_tests",
"//ios/showcase/core:eg2_tests", "//ios/showcase/core:eg2_tests",
"//ios/showcase/credential_provider:eg2_tests",
"//ios/showcase/infobars:eg2_tests", "//ios/showcase/infobars:eg2_tests",
"//ios/showcase/text_badge_view:eg2_tests", "//ios/showcase/text_badge_view:eg2_tests",
] ]
......
...@@ -16,6 +16,21 @@ ...@@ -16,6 +16,21 @@
// required. |kShowcaseUseCaseKey| is optional. // required. |kShowcaseUseCaseKey| is optional.
+ (NSArray<showcase::ModelRow*>*)model { + (NSArray<showcase::ModelRow*>*)model {
return @[ return @[
@{
showcase::kClassForDisplayKey : @"ConsentViewController",
showcase::kClassForInstantiationKey : @"ConsentViewController",
showcase::kUseCaseKey : @"Credential Provider Consent UI",
},
@{
showcase::kClassForDisplayKey : @"EmptyCredentialsViewController",
showcase::kClassForInstantiationKey : @"EmptyCredentialsViewController",
showcase::kUseCaseKey : @"Credential Provider Empty Credentials UI",
},
@{
showcase::kClassForDisplayKey : @"StaleCredentialsViewController",
showcase::kClassForInstantiationKey : @"StaleCredentialsViewController",
showcase::kUseCaseKey : @"Credential Provider Stale Credentials UI",
},
@{ @{
showcase::kClassForDisplayKey : @"ContentSuggestionsViewController", showcase::kClassForDisplayKey : @"ContentSuggestionsViewController",
showcase::kClassForInstantiationKey : @"SCContentSuggestionsCoordinator", showcase::kClassForInstantiationKey : @"SCContentSuggestionsCoordinator",
......
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("credential_provider") {
sources = []
deps = [ "//ios/chrome/credential_provider_extension/ui" ]
libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [ "credential_provider_egtest.mm" ]
deps = [
"//base",
"//ios/chrome/common/ui/confirmation_alert",
"//ios/showcase/test:eg2_test",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ui/base",
]
libs = [ "UIKit.framework" ]
}
javierrobles@chromium.org
# TEAM: ios-directory-owners@chromium.org
# OS: iOS
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/ios/ios_util.h"
#import "ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h"
#import "ios/showcase/test/showcase_eg_utils.h"
#import "ios/showcase/test/showcase_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
id<GREYMatcher> TitleMatcher() {
return grey_accessibilityID(kConfirmationAlertTitleAccessibilityIdentifier);
}
id<GREYMatcher> SubtitleMatcher() {
return grey_accessibilityID(
kConfirmationAlertSubtitleAccessibilityIdentifier);
}
id<GREYMatcher> PrimaryActionButtonMatcher() {
return grey_accessibilityID(
kConfirmationAlertPrimaryActionAccessibilityIdentifier);
}
id<GREYMatcher> MoreInfoButtonMatcher() {
return grey_accessibilityID(
kConfirmationAlertMoreInfoAccessibilityIdentifier);
}
} // namespace
// Tests for the suggestions view controller.
@interface SCCredentialProviderTestCase : ShowcaseTestCase
@end
@implementation SCCredentialProviderTestCase
// Tests ConsentViewController.
- (void)testConsentScreen {
showcase_utils::Open(@"ConsentViewController");
[[EarlGrey selectElementWithMatcher:TitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:SubtitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:PrimaryActionButtonMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:MoreInfoButtonMatcher()]
assertWithMatcher:grey_interactable()];
showcase_utils::Close();
}
// Tests ConsentViewController.
- (void)testEmptyCredentialsScreen {
showcase_utils::Open(@"EmptyCredentialsViewController");
[[EarlGrey selectElementWithMatcher:TitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:SubtitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:PrimaryActionButtonMatcher()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:MoreInfoButtonMatcher()]
assertWithMatcher:grey_nil()];
showcase_utils::Close();
}
// Tests ConsentViewController.
- (void)testStaleCredentialsScreen {
showcase_utils::Open(@"StaleCredentialsViewController");
[[EarlGrey selectElementWithMatcher:TitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:SubtitleMatcher()]
assertWithMatcher:grey_interactable()];
[[EarlGrey selectElementWithMatcher:PrimaryActionButtonMatcher()]
assertWithMatcher:grey_nil()];
[[EarlGrey selectElementWithMatcher:MoreInfoButtonMatcher()]
assertWithMatcher:grey_nil()];
showcase_utils::Close();
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment