Commit 5a2a2a10 authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS][Password Check] Navigation from Breach Dialog test coverage

This change adds test case coverage for the scenario when the Passwords
screen is shown from the Breach Dialog.

Bug: 1129871
Change-Id: I10148da8a6356a918f7d468eac7014977c3f3594
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437815
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812655}
parent 5022fb3d
......@@ -85,7 +85,9 @@ source_set("eg2_tests") {
"//base",
"//base/test:test_support",
"//components/password_manager/core/common",
"//components/strings:components_strings_grit",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/browser/ui/settings/password:password_constants",
"//ios/chrome/test:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
......@@ -93,6 +95,7 @@ source_set("eg2_tests") {
"//ios/web/public/test/http_server",
"//net:test_support",
"//testing/gtest",
"//ui/base:base",
]
frameworks = [
"UIKit.framework",
......
......@@ -11,7 +11,9 @@
@interface PasswordBreachAppInterface : NSObject
// Shows Password Breach with a default type of leak and URL.
+ (void)showPasswordBreach;
// |checkButtonPresent| indicates that password was reused and user has option
// to check all passwords.
+ (void)showPasswordBreachWithCheckButton:(BOOL)checkButtonPresent;
@end
......
......@@ -13,10 +13,11 @@
@implementation PasswordBreachAppInterface
+ (void)showPasswordBreach {
+ (void)showPasswordBreachWithCheckButton:(BOOL)checkButtonPresent {
auto handler = chrome_test_util::HandlerForActiveBrowser();
auto leakType = password_manager::CreateLeakType(
password_manager::IsSaved(true), password_manager::IsReused(false),
password_manager::IsSaved(true),
password_manager::IsReused(checkButtonPresent),
password_manager::IsSyncing(true));
[(id<PasswordBreachCommands>)handler
showPasswordBreachForLeakType:leakType
......
......@@ -2,13 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/passwords/password_breach_app_interface.h"
#import "ios/chrome/browser/ui/passwords/password_breach_constants.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/app_launch_manager.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -23,9 +30,23 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(PasswordBreachAppInterface);
#pragma clang diagnostic pop
namespace {
using chrome_test_util::ButtonWithAccessibilityLabel;
id<GREYMatcher> PasswordBreachMatcher() {
return grey_accessibilityID(kPasswordBreachViewAccessibilityIdentifier);
}
id<GREYMatcher> PasswordListMatcher() {
return grey_accessibilityID(kPasswordsTableViewId);
}
id<GREYMatcher> CheckPasswordButton() {
return grey_allOf(ButtonWithAccessibilityLabel(base::SysUTF16ToNSString(
l10n_util::GetStringUTF16(IDS_LEAK_CHECK_CREDENTIALS))),
grey_interactable(), nullptr);
}
} // namespace
@interface PasswordBreachTestCase : ChromeTestCase
......@@ -36,9 +57,27 @@ id<GREYMatcher> PasswordBreachMatcher() {
#pragma mark - Tests
- (void)testPasswordBreachIsPresented {
[PasswordBreachAppInterface showPasswordBreach];
[PasswordBreachAppInterface showPasswordBreachWithCheckButton:NO];
[[EarlGrey selectElementWithMatcher:PasswordBreachMatcher()]
assertWithMatcher:grey_notNil()];
}
// Tests that Check password button redirects to the Passwords List.
- (void)testPasswordBreachRedirectToPasswords {
// TODO(crbug.com/1096986): Remove it once feature is enabled by default.
AppLaunchConfiguration config;
config.features_enabled.push_back(password_manager::features::kPasswordCheck);
[[AppLaunchManager sharedManager] ensureAppLaunchedWithConfiguration:config];
[PasswordBreachAppInterface showPasswordBreachWithCheckButton:YES];
[[EarlGrey selectElementWithMatcher:PasswordBreachMatcher()]
assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:CheckPasswordButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:PasswordListMatcher()]
assertWithMatcher:grey_notNil()];
}
@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