1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/i18n/time_formatting.h"
#include "base/time/time.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/ash/interactive/interactive_ash_test.h"
#include "chrome/test/base/ash/interactive/network/shill_service_util.h"
#include "chrome/test/base/ash/interactive/settings/interactive_uitest_elements.h"
#include "chromeos/ash/components/dbus/shill/fake_shill_manager_client.h"
#include "chromeos/ash/components/dbus/shill/fake_shill_service_client.h"
#include "chromeos/ash/services/connectivity/public/cpp/fake_passpoint_service.h"
#include "chromeos/ash/services/connectivity/public/cpp/fake_passpoint_subscription.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
#include "ui/base/interaction/element_identifier.h"
namespace ash {
namespace {
constexpr char kPasspointId[] = "fake_id";
constexpr char kPasspointFriendlyName[] = "fake_friendly_name";
constexpr char kPasspointProvisioningSource[] = "fake_provisioning_source";
constexpr char kPasspointDomain[] = "fake_domain";
constexpr base::Time kPasspointExpirationDate =
base::Time::FromDeltaSinceWindowsEpoch(base::Days(160000));
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kOSSettingsId);
class PasspointUiInteractiveUiTest : public InteractiveAshTest {
protected:
// InteractiveAshTest:
void SetUpOnMainThread() override {
InteractiveAshTest::SetUpOnMainThread();
// Set up context for element tracking for InteractiveBrowserTest.
SetupContextWidget();
// Ensure the OS Settings app is installed.
InstallSystemApps();
if (!connectivity::FakePasspointService::IsInitialized()) {
connectivity::FakePasspointService::Initialize();
}
connectivity::FakePasspointService::Get()->ClearAll();
connectivity::FakePasspointService::Get()->AddFakePasspointSubscription(
connectivity::FakePasspointSubscription(
kPasspointId, kPasspointFriendlyName, kPasspointProvisioningSource,
/*trusted_ca=*/std::nullopt,
kPasspointExpirationDate.InMillisecondsSinceUnixEpoch(),
std::vector<std::string>({kPasspointDomain})));
wifi_service_info_.ConfigureService(/*connected=*/true);
ShillServiceClient::Get()->GetTestInterface()->SetServiceProperty(
wifi_service_info_.service_path(), shill::kPasspointIDProperty,
base::Value(kPasspointId));
}
const std::string wifiName() const {
return wifi_service_info_.service_name();
}
private:
const ShillServiceInfo wifi_service_info_{/*id=*/0, shill::kTypeWifi};
};
IN_PROC_BROWSER_TEST_F(PasspointUiInteractiveUiTest,
PasspointSubscriptionSubpageUi) {
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
Log("Navigate to for passpoint subscriptions subpage"),
NavigateToPasspointSubscriptionSubpage(kOSSettingsId,
kPasspointFriendlyName),
Log("Checking for expiration date"),
WaitForElementTextContains(
kOSSettingsId, settings::wifi::PasspointSubpageExpirationDate(),
base::UnlocalizedTimeFormatWithPattern(kPasspointExpirationDate,
"M/d/yyyy")),
Log("Checking for provider name"),
WaitForElementTextContains(
kOSSettingsId, settings::wifi::PasspointSubpageProviderSource(),
kPasspointProvisioningSource),
Log("Expand domain list"),
ClickElement(kOSSettingsId,
settings::wifi::PasspointSubpageDomainExpansionButton()),
WaitForElementOpened(kOSSettingsId,
settings::wifi::PasspointSubpageDomainList()),
Log("Checking for domain"),
WaitForElementTextContains(
kOSSettingsId, settings::wifi::PasspointSubpageDomainListItem(),
kPasspointDomain),
Log("Checking for associated networks"),
WaitForElementTextContains(
kOSSettingsId,
settings::wifi::PasspointSubpageAssociatedNetworksListItem(),
wifiName()),
Log("Click on associated network and go to its detail page"),
ClickElement(
kOSSettingsId,
settings::wifi::PasspointSubpageAssociatedNetworksListItem()),
WaitForElementTextContains(
kOSSettingsId, settings::InternetSettingsSubpageTitle(), wifiName()),
Log("Test complete"));
}
IN_PROC_BROWSER_TEST_F(PasspointUiInteractiveUiTest,
RemovePasspointFromKnownNetworkSubpage) {
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
Log("Navigate to for Known Networks subpage"),
NavigateToKnownNetworksPage(kOSSettingsId),
Log("Check the subscription appear in the passpoint list"),
WaitForElementTextContains(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointSubscriptionItem(),
kPasspointFriendlyName),
Log("Open drop down menu"),
WaitForElementEnabled(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointMoreButton()),
ClickElement(kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointMoreButton()),
WaitForElementOpened(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointDotsMenu()),
Log("Click on Forget button"),
WaitForElementExists(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointSubscriptionForget()),
ClickElement(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointSubscriptionForget()),
Log("Verify the passpoint subscription section not shown"),
WaitForElementDisplayNone(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointSubsciptions()),
Log("Test complete"));
}
IN_PROC_BROWSER_TEST_F(PasspointUiInteractiveUiTest,
RemovePasspointFromPasspointSubpage) {
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
Log("Navigate to for passpoint subscriptions subpage"),
NavigateToPasspointSubscriptionSubpage(kOSSettingsId,
kPasspointFriendlyName),
Log("Click on Remove button and pop up remove dialog"),
WaitForElementEnabled(kOSSettingsId,
settings::wifi::PasspointSubpageRemoveButton()),
ClickElement(kOSSettingsId,
settings::wifi::PasspointSubpageRemoveButton()),
WaitForElementExists(kOSSettingsId,
settings::wifi::PasspointSubpageRemoveDialog()),
Log("Click on confirm button"),
WaitForElementEnabled(
kOSSettingsId,
settings::wifi::PasspointSubpageRemoveDialogConfirmButton()),
ClickElement(kOSSettingsId,
settings::wifi::PasspointSubpageRemoveDialogConfirmButton()),
Log("Verify it goes back to Known Networks subpage and the passpoint "
"subscription section disappear"),
WaitForElementExists(kOSSettingsId,
settings::wifi::KnownNetworksSubpage()),
WaitForElementDisplayNone(
kOSSettingsId,
settings::wifi::KnownNetworksSubpagePasspointSubsciptions()),
Log("Test complete"));
}
} // namespace
} // namespace ash
|