blob: 18fd6aad1c2f64666e4decdc206a2a67e721355e [file] [log] [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "base/strings/sys_string_conversions.h"
#import "components/commerce/core/commerce_feature_list.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.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/earl_grey_test.h"
#import "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using chrome_test_util::ButtonWithAccessibilityLabelId;
using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuNotificationsButton;
using chrome_test_util::SettingsNotificationsTableView;
// Integration tests using the Price Notifications settings screen.
@interface NotificationsTestCase : ChromeTestCase
@end
@implementation NotificationsTestCase
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
// Feature parameters follow a key/value format to enable or disable
// parameters.
std::string params =
":enable_price_tracking/true/enable_price_notification/true";
std::string priceNotificationsFlag =
std::string(commerce::kCommercePriceTracking.name) + params;
std::string shoppingListFlag = std::string("ShoppingList");
std::string notificationMenuItemFlag =
std::string("NotificationSettingsMenuItem");
config.additional_args.push_back(
"--enable-features=" + priceNotificationsFlag + "," + shoppingListFlag +
"," + notificationMenuItemFlag);
return config;
}
// Tests that the settings page is dismissed by swiping down from the top.
- (void)testPriceNotificationsSwipeDown {
// Opens price notifications setting.
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:SettingsMenuNotificationsButton()];
// Check that Price Notifications TableView is presented.
[[EarlGrey selectElementWithMatcher:SettingsNotificationsTableView()]
assertWithMatcher:grey_notNil()];
// Swipe TableView down.
[[EarlGrey selectElementWithMatcher:SettingsNotificationsTableView()]
performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
// Check that Settings has been dismissed.
[[EarlGrey selectElementWithMatcher:SettingsNotificationsTableView()]
assertWithMatcher:grey_nil()];
}
@end