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
|
// 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 <string>
#include "chrome/test/base/ash/interactive/hotspot/hotspot_config_observer.h"
#include "chrome/test/base/ash/interactive/hotspot/hotspot_state_observer.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/shill_manager_client.h"
#include "chromeos/ash/components/dbus/shill/shill_service_client.h"
#include "third_party/cros_system_api/dbus/shill/dbus-constants.h"
#include "ui/base/interaction/element_identifier.h"
namespace ash {
namespace {
const char kTestSSID[] = "testssid";
DEFINE_LOCAL_STATE_IDENTIFIER_VALUE(HotspotStateObserver, kHotspotStateService);
class HotspotUpdateConfigurationInteractiveUITest : 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();
ShillServiceClient::Get()->GetTestInterface()->AddService(
shill_service_info().service_path(),
shill_service_info().service_guid(),
shill_service_info().service_name(), shill::kTypeCellular,
shill::kStateOnline, /*visible=*/true);
auto* shill_manager_client = ShillManagerClient::Get()->GetTestInterface();
shill_manager_client->SetSimulateCheckTetheringReadinessResult(
FakeShillSimulatedResult::kSuccess, shill::kTetheringReadinessReady);
}
const ShillServiceInfo& shill_service_info() { return shill_service_info_; }
private:
const ShillServiceInfo shill_service_info_ =
ShillServiceInfo(/*id=*/0, shill::kTypeCellular);
};
IN_PROC_BROWSER_TEST_F(HotspotUpdateConfigurationInteractiveUITest,
UpdateHotspotConfiguration) {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kOSSettingsId);
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
Log("Navigating to the internet page"),
NavigateSettingsToInternetPage(kOSSettingsId),
Log("Waiting for hotspot summary item to exist then click it"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotSummaryItem()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotSummaryItem()),
Log("Wait for the configure button to exist and then click it"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotConfigureButton()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotConfigureButton()),
Log("Enter the new hotspot SSID and then save it"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotSSIDInput()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotSSIDInput()),
SendTextAsKeyEvents(kOSSettingsId, kTestSSID),
ClickElement(kOSSettingsId, settings::hotspot::HotspotDialogSaveButton()),
Log("Wait for the new hotspot SSID to show up"),
WaitForElementTextContains(kOSSettingsId,
settings::hotspot::HotspotSSID(),
/*text=*/kTestSSID),
Log("Test complete"));
}
IN_PROC_BROWSER_TEST_F(HotspotUpdateConfigurationInteractiveUITest,
UpdateHotspotConfigurationWithHotspotOn) {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE(kOSSettingsId);
ui::ElementContext context =
LaunchSystemWebApp(SystemWebAppType::SETTINGS, kOSSettingsId);
ShillManagerClient::Get()
->GetTestInterface()
->SetSimulateTetheringEnableResult(FakeShillSimulatedResult::kSuccess,
shill::kTetheringEnableResultSuccess);
ShillManagerClient::Get()->GetTestInterface()->SetInteractiveDelay(
base::Seconds(2));
HotspotConfigObserver observer;
// Run the following steps with the OS Settings context set as the default.
RunTestSequenceInContext(
context,
Log("Navigating to the internet page"),
NavigateSettingsToInternetPage(kOSSettingsId),
Log("Waiting for hotspot summary item to exist"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotSummaryItem()),
Log("Wait for hotspot toggle to be enabled then click it"),
WaitForElementEnabled(kOSSettingsId, settings::hotspot::HotspotToggle()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotToggle()),
Log("Wait for the hotspot state to be enabled"),
ObserveState(kHotspotStateService,
std::make_unique<HotspotStateObserver>()),
WaitForState(kHotspotStateService,
hotspot_config::mojom::HotspotState::kEnabled),
WaitForToggleState(kOSSettingsId, settings::hotspot::HotspotToggle(),
true),
Log("Wait for hotspot summary item to exist then click it"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotSummaryItem()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotSummaryItem()),
Log("Wait for the configure button to exist and then click it"),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotConfigureButton()),
ClickElement(kOSSettingsId, settings::hotspot::HotspotConfigureButton()),
Log("Enter the new hotspot SSID and then save it"),
ClearInputAndEnterText(kOSSettingsId,
settings::hotspot::HotspotSSIDInput(), kTestSSID),
ClickElement(kOSSettingsId, settings::hotspot::HotspotDialogSaveButton()),
Log("Wait for configure window to clear"),
WaitForElementDoesNotExist(kOSSettingsId,
settings::hotspot::HotspotSSIDInput()),
Log("Wait for hotspot to be disabled"),
WaitForState(kHotspotStateService,
hotspot_config::mojom::HotspotState::kDisabled),
Log("Wait for hotspot to be enabled"),
WaitForState(kHotspotStateService,
hotspot_config::mojom::HotspotState::kEnabled),
WaitForElementExists(kOSSettingsId,
settings::hotspot::HotspotClientCountItem()),
Log("Wait for the new hotspot SSID to show up"),
WaitForElementTextContains(kOSSettingsId,
settings::hotspot::HotspotSSID(),
/*text=*/kTestSSID),
Log("Test complete"));
}
} // namespace
} // namespace ash
|