credential_provider_egtest.mm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/ios/ios_util.h"
  5. #import "ios/chrome/common/ui/confirmation_alert/confirmation_alert_view_controller.h"
  6. #import "ios/chrome/common/ui/promo_style/constants.h"
  7. #import "ios/showcase/test/showcase_eg_utils.h"
  8. #import "ios/showcase/test/showcase_test_case.h"
  9. #import "ios/testing/earl_grey/earl_grey_test.h"
  10. #include "ui/base/l10n/l10n_util_mac.h"
  11. #if !defined(__has_feature) || !__has_feature(objc_arc)
  12. #error "This file requires ARC support."
  13. #endif
  14. namespace {
  15. id<GREYMatcher> ConfirmationAlertTitleMatcher() {
  16. return grey_accessibilityID(kConfirmationAlertTitleAccessibilityIdentifier);
  17. }
  18. id<GREYMatcher> ConfirmationAlertSubtitleMatcher() {
  19. return grey_accessibilityID(
  20. kConfirmationAlertSubtitleAccessibilityIdentifier);
  21. }
  22. id<GREYMatcher> ConfirmationAlertPrimaryActionButtonMatcher() {
  23. return grey_accessibilityID(
  24. kConfirmationAlertPrimaryActionAccessibilityIdentifier);
  25. }
  26. id<GREYMatcher> ConfirmationAlertMoreInfoButtonMatcher() {
  27. return grey_accessibilityID(
  28. kConfirmationAlertMoreInfoAccessibilityIdentifier);
  29. }
  30. id<GREYMatcher> PromoStyleTitleMatcher() {
  31. return grey_accessibilityID(kPromoStyleTitleAccessibilityIdentifier);
  32. }
  33. id<GREYMatcher> PromoStyleSubtitleMatcher() {
  34. return grey_accessibilityID(kPromoStyleSubtitleAccessibilityIdentifier);
  35. }
  36. id<GREYMatcher> PromoStylePrimaryActionButtonMatcher() {
  37. return grey_accessibilityID(kPromoStylePrimaryActionAccessibilityIdentifier);
  38. }
  39. id<GREYMatcher> PromoStyleMoreInfoButtonMatcher() {
  40. return grey_accessibilityID(
  41. kPromoStyleLearnMoreActionAccessibilityIdentifier);
  42. }
  43. } // namespace
  44. // Tests for the suggestions view controller.
  45. @interface SCCredentialProviderTestCase : ShowcaseTestCase
  46. @end
  47. @implementation SCCredentialProviderTestCase
  48. // Tests ConsentViewController.
  49. - (void)testConsentScreen {
  50. showcase_utils::Open(@"ConsentViewController");
  51. [[EarlGrey selectElementWithMatcher:PromoStyleTitleMatcher()]
  52. assertWithMatcher:grey_interactable()];
  53. [[EarlGrey selectElementWithMatcher:PromoStyleSubtitleMatcher()]
  54. assertWithMatcher:grey_interactable()];
  55. [[EarlGrey selectElementWithMatcher:PromoStylePrimaryActionButtonMatcher()]
  56. assertWithMatcher:grey_interactable()];
  57. [[EarlGrey selectElementWithMatcher:PromoStyleMoreInfoButtonMatcher()]
  58. assertWithMatcher:grey_interactable()];
  59. showcase_utils::Close();
  60. }
  61. // Tests ConsentViewController.
  62. - (void)testEmptyCredentialsScreen {
  63. showcase_utils::Open(@"EmptyCredentialsViewController");
  64. [[EarlGrey selectElementWithMatcher:ConfirmationAlertTitleMatcher()]
  65. assertWithMatcher:grey_interactable()];
  66. [[EarlGrey selectElementWithMatcher:ConfirmationAlertSubtitleMatcher()]
  67. assertWithMatcher:grey_interactable()];
  68. [[EarlGrey
  69. selectElementWithMatcher:ConfirmationAlertPrimaryActionButtonMatcher()]
  70. assertWithMatcher:grey_nil()];
  71. [[EarlGrey selectElementWithMatcher:ConfirmationAlertMoreInfoButtonMatcher()]
  72. assertWithMatcher:grey_nil()];
  73. showcase_utils::Close();
  74. }
  75. // Tests ConsentViewController.
  76. - (void)testStaleCredentialsScreen {
  77. showcase_utils::Open(@"StaleCredentialsViewController");
  78. [[EarlGrey selectElementWithMatcher:ConfirmationAlertTitleMatcher()]
  79. assertWithMatcher:grey_interactable()];
  80. [[EarlGrey selectElementWithMatcher:ConfirmationAlertSubtitleMatcher()]
  81. assertWithMatcher:grey_interactable()];
  82. [[EarlGrey
  83. selectElementWithMatcher:ConfirmationAlertPrimaryActionButtonMatcher()]
  84. assertWithMatcher:grey_nil()];
  85. [[EarlGrey selectElementWithMatcher:ConfirmationAlertMoreInfoButtonMatcher()]
  86. assertWithMatcher:grey_nil()];
  87. showcase_utils::Close();
  88. }
  89. @end