Performance tests (#1301)

* Add signposts to performance tests.

- Update flow to include support for the migration screen.

* If the welcome screen shows, click on the button.

* Ensure a clean simulator each run.

* Add accessibility identifier for migration screen if required.

* Handle walking into the room and back out again.

* use iphone 14 pro to match what's used in xcode.

* Remove ApplicationTests as duplicated in LoginTests.

We measure app startup time in LoginTests as part of the flow - we may as well avoid spending 60s doing only that measurement in ApplicationTests

* Sleep 10s, the ui is otherwise showing up in random order.

* Revert "Remove ApplicationTests as duplicated in LoginTests."

This reverts commit 8670710315bcd0d6c3c3046f534b32b4c728b837.

* Update script to parse out correct values from results file.

* Allow cancellation of password prompt in any order.

* Remove test timeout, performance tests will always take a while.

* Adjust parsing further

* Remove ApplicationTests.

* Move to a more elegant way to wait for something to disappear.

* Linting.

* Fix unit tests.

---------

Co-authored-by: Doug <douglase@element.io>
Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Michael Kaye 2023-07-11 10:32:24 +01:00 committed by GitHub
parent 28fa1140b7
commit 5e97a4a0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 207 additions and 69 deletions

View File

@ -93,7 +93,6 @@
2352C541AF857241489756FF /* MockRoomSummaryProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F7D42E66E939B709C1EC390 /* MockRoomSummaryProvider.swift */; };
23701DE32ACD6FD40AA992C3 /* MediaUploadingPreprocessorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE203026B9AD3DB412439866 /* MediaUploadingPreprocessorTests.swift */; };
237FC70AA257B935F53316BA /* SessionVerificationControllerProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C55D7E514F9DE4E3D72FDCAD /* SessionVerificationControllerProxy.swift */; };
23B2CD5A06B16055BDDD0994 /* ApplicationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44D8C8431416EB8DFEC7E235 /* ApplicationTests.swift */; };
24906A1E82D0046655958536 /* MessageComposer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18CF12478983A5EB390FB26 /* MessageComposer.swift */; };
24A75F72EEB7561B82D726FD /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2141693488CE5446BB391964 /* Date.swift */; };
24BDDD09A90B8BFE3793F3AA /* ClientProxyProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6033779EB37259F27F938937 /* ClientProxyProtocol.swift */; };
@ -317,6 +316,7 @@
764AFCC225B044CF5F9B41E5 /* PaginationIndicatorRoomTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42EEA67A6796BDC2761619C5 /* PaginationIndicatorRoomTimelineView.swift */; };
76BA28216FBAF83B2D86A027 /* InvitesScreenCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA2A71915C1F075E403F559C /* InvitesScreenCell.swift */; };
7756C4E90CABE6F14F7920A0 /* BugReportUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6FEA87EA3752203065ECE27 /* BugReportUITests.swift */; };
77920AFA8091AC6B9F190C90 /* Signposter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752A0EB49BF5BCEA37EDF7A3 /* Signposter.swift */; };
77D7DAA41AAB36800C1F2E2D /* RoomTimelineProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 095AED4CF56DFF3EB7BB84C8 /* RoomTimelineProviderProtocol.swift */; };
77FACC29F98FE2E65BBB6A5F /* ServerSelectionUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 054F469E433864CC6FE6EE8E /* ServerSelectionUITests.swift */; };
784592335560C2E91D32D177 /* DeveloperOptionsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06B098A612DCB5A7358EECD5 /* DeveloperOptionsScreenModels.swift */; };
@ -368,6 +368,7 @@
878070573C7BF19E735707B4 /* RoomTimelineItemProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DE8D25D6A91030175D52A20 /* RoomTimelineItemProperties.swift */; };
87CEDB8A0696F0D5AE2ABB28 /* test_audio.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = D5E26C54362206BBDD096D83 /* test_audio.mp3 */; };
8810A2A30A68252EBB54EE05 /* HomeScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 71BC7CA1BC1041E93077BBA1 /* HomeScreenModels.swift */; };
88356DE7F2AD243AB10C7B7A /* Signposter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 752A0EB49BF5BCEA37EDF7A3 /* Signposter.swift */; };
8868ACFA45E5B5E19514B575 /* LegalInformationScreenUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACCC1874C122E2BBE648B8F5 /* LegalInformationScreenUITests.swift */; };
88F348E2CB14FF71CBBB665D /* AudioRoomTimelineItemContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7475C5AE20BA896930907EA8 /* AudioRoomTimelineItemContent.swift */; };
890F0D453FE388756479AC97 /* AnalyticsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C687844F60BFF532D49A994C /* AnalyticsTests.swift */; };
@ -976,7 +977,6 @@
42C64A14EE89928207E3B42B /* AnalyticsSettingsScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsSettingsScreenModels.swift; sourceTree = "<group>"; };
42EEA67A6796BDC2761619C5 /* PaginationIndicatorRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationIndicatorRoomTimelineView.swift; sourceTree = "<group>"; };
4481799F455B3DA243BDA2AC /* ShareToMapsAppActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareToMapsAppActivity.swift; sourceTree = "<group>"; };
44D8C8431416EB8DFEC7E235 /* ApplicationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationTests.swift; sourceTree = "<group>"; };
450E04B2A976CC4C8CC1807C /* EmoteRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmoteRoomTimelineItem.swift; sourceTree = "<group>"; };
4549FCB53F43DB0B278374BC /* TemplateScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TemplateScreen.swift; sourceTree = "<group>"; };
4552D3466B1453F287223ADA /* SwipeRightAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwipeRightAction.swift; sourceTree = "<group>"; };
@ -1116,6 +1116,7 @@
7475C5AE20BA896930907EA8 /* AudioRoomTimelineItemContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRoomTimelineItemContent.swift; sourceTree = "<group>"; };
748AE77AC3B0A01223033B87 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
74DD0855F2F76D47E5555082 /* MediaUploadPreviewScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaUploadPreviewScreenCoordinator.swift; sourceTree = "<group>"; };
752A0EB49BF5BCEA37EDF7A3 /* Signposter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Signposter.swift; sourceTree = "<group>"; };
75697AB5E64A12F1F069F511 /* EncryptedHistoryRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptedHistoryRoomTimelineView.swift; sourceTree = "<group>"; };
75910F5A36EA8FF9BAD08D18 /* MigrationScreenUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MigrationScreenUITests.swift; sourceTree = "<group>"; };
772334731A8BF8E6D90B194D /* LocationRoomTimelineView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationRoomTimelineView.swift; sourceTree = "<group>"; };
@ -2119,6 +2120,7 @@
5445FCE0CE15E634FDC1A2E2 /* AnalyticsService.swift */,
A6B891A6DA826E2461DBB40F /* PHGPostHogConfiguration.swift */,
1715E3D7F53C0748AA50C91C /* PostHogAnalyticsClient.swift */,
752A0EB49BF5BCEA37EDF7A3 /* Signposter.swift */,
3A304097A59704AC9B869EC6 /* Helpers */,
);
path = Analytics;
@ -2136,7 +2138,6 @@
isa = PBXGroup;
children = (
D33116993D54FADC0C721C1F /* Application.swift */,
44D8C8431416EB8DFEC7E235 /* ApplicationTests.swift */,
2D256FEE2F1AF1E51D39B622 /* LoginTests.swift */,
9C4048041C1A6B20CB97FD18 /* TestMeasurementParser.swift */,
);
@ -4525,6 +4526,7 @@
1C8BC70A18060677E295A846 /* ShareToMapsAppActivity.swift in Sources */,
8922219C5C934C4155E8CA50 /* SharedUserDefaultsKeys.swift in Sources */,
274CE3C986841D15FD530BF5 /* ShimmerModifier.swift in Sources */,
77920AFA8091AC6B9F190C90 /* Signposter.swift in Sources */,
8BC8EF6705A78946C1F22891 /* SoftLogoutScreen.swift in Sources */,
A3A7A05E8F9B7EB0E1A09A2A /* SoftLogoutScreenCoordinator.swift in Sources */,
F86102DC2C68BBBB0521BAAE /* SoftLogoutScreenModels.swift in Sources */,
@ -4691,9 +4693,9 @@
files = (
DC08ADC41E792086A340A8B3 /* AccessibilityIdentifiers.swift in Sources */,
1702981A8085BE4FB0EC001B /* Application.swift in Sources */,
23B2CD5A06B16055BDDD0994 /* ApplicationTests.swift in Sources */,
07240B7159A3990C4C2E8FFC /* LoginTests.swift in Sources */,
A439B456D0761D6541745CC3 /* NSRegularExpresion.swift in Sources */,
88356DE7F2AD243AB10C7B7A /* Signposter.swift in Sources */,
290FDB0FFDC2F1DDF660343E /* TestMeasurementParser.swift in Sources */,
B444F9C184A377C1B481F07F /* XCUIElement.swift in Sources */,
);

View File

@ -353,7 +353,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
navigationSplitCoordinator: navigationSplitCoordinator,
bugReportService: ServiceLocator.shared.bugReportService,
roomTimelineControllerFactory: RoomTimelineControllerFactory(),
appSettings: ServiceLocator.shared.settings)
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
userSessionFlowCoordinator.callback = { [weak self] action in
switch action {
@ -550,6 +551,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
}
private func startSync() {
ServiceLocator.shared.analytics.signpost.beginSync()
guard let userSession else {
fatalError("User session not setup")
}
@ -574,6 +576,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationCoordinatorDelegate,
case .startedUpdating:
showLoadingIndicator()
case .receivedSyncUpdate:
ServiceLocator.shared.analytics.signpost.endSync()
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(identifier)
default:
break

View File

@ -28,6 +28,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
private let bugReportService: BugReportServiceProtocol
private let roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol
private let appSettings: AppSettings
private let analytics: AnalyticsService
private let stateMachine: UserSessionFlowCoordinatorStateMachine
private let roomFlowCoordinator: RoomFlowCoordinator
@ -46,13 +47,15 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
navigationSplitCoordinator: NavigationSplitCoordinator,
bugReportService: BugReportServiceProtocol,
roomTimelineControllerFactory: RoomTimelineControllerFactoryProtocol,
appSettings: AppSettings) {
appSettings: AppSettings,
analytics: AnalyticsService) {
stateMachine = UserSessionFlowCoordinatorStateMachine()
self.userSession = userSession
self.navigationSplitCoordinator = navigationSplitCoordinator
self.bugReportService = bugReportService
self.roomTimelineControllerFactory = roomTimelineControllerFactory
self.appSettings = appSettings
self.analytics = analytics
sidebarNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
detailNavigationStackCoordinator = NavigationStackCoordinator(navigationSplitCoordinator: navigationSplitCoordinator)
@ -64,8 +67,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
navigationStackCoordinator: detailNavigationStackCoordinator,
navigationSplitCoordinator: navigationSplitCoordinator,
emojiProvider: EmojiProvider(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
appSettings: appSettings,
analytics: analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
setupStateMachine()
@ -73,9 +76,11 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
roomFlowCoordinator.actions.sink { action in
switch action {
case .presentedRoom(let roomID):
self.analytics.signpost.beginRoomFlow(roomID)
self.stateMachine.processEvent(.selectRoom(roomId: roomID))
case .dismissedRoom:
self.stateMachine.processEvent(.deselectRoom)
self.analytics.signpost.endRoomFlow()
}
}
.store(in: &cancellables)

View File

@ -33,7 +33,9 @@ struct A11yIdentifiers {
static let roomMemberDetailsScreen = RoomMemberDetailsScreen()
static let createRoomScreen = CreateRoomScreen()
static let invitesScreen = InvitesScreen()
static let welcomeScreen = WelcomeScreen()
static let migrationScreen = MigrationScreen()
struct AnalyticsPromptScreen {
let title = "analytics_prompt-title"
let enable = "analytics_prompt-enable"
@ -59,8 +61,10 @@ struct A11yIdentifiers {
let settings = "home_screen-settings"
let signOut = "home_screen-sign_out"
let verificationBannerContinue = "home_screen-verification_continue"
let roomNamePrefix = "home_screen-room_name"
func roomName(_ name: String) -> String {
"home_screen-room_name:\(name)"
"\(roomNamePrefix):\(name)"
}
}
@ -142,4 +146,12 @@ struct A11yIdentifiers {
let roomName = "create_room-room_name"
let roomTopic = "create_room-room_topic"
}
struct WelcomeScreen {
let letsGo = "welcome_screen-lets_go"
}
struct MigrationScreen {
let message = "migration_screen-message"
}
}

View File

@ -76,6 +76,7 @@ struct ShimmerOverlay_Previews: PreviewProvider {
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
static var previews: some View {

View File

@ -165,6 +165,7 @@ class AuthenticationCoordinator: CoordinatorProtocol {
private func showLoginScreen() {
let parameters = LoginScreenCoordinatorParameters(authenticationService: authenticationService,
analytics: analytics,
userIndicatorController: userIndicatorController)
let coordinator = LoginScreenCoordinator(parameters: parameters)

View File

@ -21,6 +21,7 @@ struct LoginScreenCoordinatorParameters {
/// The service used to authenticate the user.
let authenticationService: AuthenticationServiceProxyProtocol
let analytics: AnalyticsService
let userIndicatorController: UserIndicatorControllerProtocol
}
@ -119,15 +120,18 @@ final class LoginScreenCoordinator: CoordinatorProtocol {
startLoading(isInteractionBlocking: true)
Task {
parameters.analytics.signpost.beginLogin()
switch await authenticationService.login(username: username,
password: password,
initialDeviceName: UIDevice.current.initialDeviceName,
deviceID: nil) {
case .success(let userSession):
callback?(.signedIn(userSession))
parameters.analytics.signpost.endLogin()
stopLoading()
case .failure(let error):
stopLoading()
parameters.analytics.signpost.endLogin()
switch error {
case .isOnWaitlist:
callback?(.isOnWaitlist(.init(username: username,

View File

@ -52,6 +52,7 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
attributedStringBuilder: parameters.attributedStringBuilder,
selectedRoomPublisher: parameters.selectedRoomPublisher,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
viewModel.callback = { [weak self] action in

View File

@ -23,6 +23,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
private let userSession: UserSessionProtocol
private let attributedStringBuilder: AttributedStringBuilderProtocol
private let appSettings: AppSettings
private let analytics: AnalyticsService
private let userIndicatorController: UserIndicatorControllerProtocol
private let roomSummaryProvider: RoomSummaryProviderProtocol?
@ -38,10 +39,12 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
attributedStringBuilder: AttributedStringBuilderProtocol,
selectedRoomPublisher: CurrentValuePublisher<String?, Never>,
appSettings: AppSettings,
analytics: AnalyticsService,
userIndicatorController: UserIndicatorControllerProtocol) {
self.userSession = userSession
self.attributedStringBuilder = attributedStringBuilder
self.appSettings = appSettings
self.analytics = analytics
self.userIndicatorController = userIndicatorController
roomSummaryProvider = userSession.clientProxy.roomSummaryProvider
@ -98,6 +101,11 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
return
}
// End the initial sync performance timing once the room list is about to be displayed.
if roomListMode == .rooms, self.state.roomListMode == .skeletons {
analytics.signpost.endSync()
}
self.state.roomListMode = roomListMode
MXLog.info("Received room summary provider update, setting view room list mode to \"\(self.state.roomListMode)\"")

View File

@ -228,6 +228,7 @@ struct HomeScreen_Previews: PreviewProvider {
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
return NavigationStack {

View File

@ -177,6 +177,7 @@ struct HomeScreenRoomCell_Previews: PreviewProvider {
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
let rooms: [HomeScreenRoom] = summaryProvider.roomListPublisher.value.compactMap { summary -> HomeScreenRoom? in

View File

@ -43,6 +43,7 @@ struct MigrationScreen: View {
.font(.compound.bodyLG)
.multilineTextAlignment(.center)
.foregroundColor(.compound.textPrimary)
.accessibilityIdentifier(A11yIdentifiers.migrationScreen.message)
}
}
}

View File

@ -94,6 +94,7 @@ struct WelcomeScreen: View {
Text(context.viewState.buttonTitle)
}
.buttonStyle(.elementAction(.xLarge))
.accessibilityIdentifier(A11yIdentifiers.welcomeScreen.letsGo)
}
}

View File

@ -35,6 +35,10 @@ class AnalyticsService {
private let client: AnalyticsClientProtocol
private let appSettings: AppSettings
private let bugReportService: BugReportServiceProtocol
/// A signpost client for performance testing the app. This client doesn't respect the
/// `isRunning` state or behave any differently when `start`/`reset` are called.
let signpost = Signposter()
init(client: AnalyticsClientProtocol, appSettings: AppSettings, bugReportService: BugReportServiceProtocol) {
self.client = client

View File

@ -0,0 +1,84 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import OSLog
/// A simple wrapper around OSSignposter for easy performance testing.
class Signposter {
/// The underlying signposter.
private let signposter = OSSignposter(subsystem: subsystem, category: category)
/// A logger instance to capture any errors.
private let logger = Logger(subsystem: subsystem, category: category)
/// Signpost name constants.
enum Name {
static let login: StaticString = "Login"
static let sync: StaticString = "Sync"
static let roomFlow: StaticString = "RoomFlow"
}
static let subsystem = "ElementX"
static let category = "PerformanceTests"
// MARK: - Login
private var loginState: OSSignpostIntervalState?
func beginLogin() {
loginState = signposter.beginInterval(Name.login)
}
func endLogin() {
guard let loginState else {
logger.error("Missing login state.")
return
}
signposter.endInterval(Name.login, loginState)
self.loginState = nil
}
// MARK: - Sync
private var syncState: OSSignpostIntervalState?
func beginSync() {
syncState = signposter.beginInterval(Name.sync)
}
func endSync() {
guard let syncState else { return }
signposter.endInterval(Name.sync, syncState)
self.syncState = nil
}
// MARK: - Room Flow
private var roomFlowState: OSSignpostIntervalState?
func beginRoomFlow(_ name: String) {
roomFlowState = signposter.beginInterval(Name.roomFlow)
signposter.emitEvent("RoomName", "\(name, privacy: .auto(mask: .hash))")
}
func endRoomFlow() {
guard let roomFlowState else { return }
signposter.endInterval(Name.roomFlow, roomFlowState)
self.roomFlowState = nil
}
}

View File

@ -78,6 +78,7 @@ class MockScreen: Identifiable {
case .login:
let navigationStackCoordinator = NavigationStackCoordinator()
let coordinator = LoginScreenCoordinator(parameters: .init(authenticationService: MockAuthenticationServiceProxy(),
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController))
navigationStackCoordinator.setRootCoordinator(coordinator)
return navigationStackCoordinator
@ -336,7 +337,8 @@ class MockScreen: Identifiable {
navigationSplitCoordinator: navigationSplitCoordinator,
bugReportService: BugReportServiceMock(),
roomTimelineControllerFactory: MockRoomTimelineControllerFactory(),
appSettings: ServiceLocator.shared.settings)
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
coordinator.start()

View File

@ -1,34 +0,0 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import XCTest
class ApplicationTests: XCTestCase {
func testLaunchPerformance() throws {
let parser = TestMeasurementParser()
parser.capture(testCase: self) {
self.measure(metrics: [XCTApplicationLaunchMetric()]) {
Application.launch()
}
}
guard let actualDuration = parser.valueForMetric(.appLaunch) else {
XCTFail("Couldn't retrieve app launch duration")
return
}
}
}

View File

@ -20,7 +20,15 @@ class LoginTests: XCTestCase {
func testLoginFlow() throws {
let parser = TestMeasurementParser()
parser.capture(testCase: self) {
self.measure(metrics: [XCTClockMetric()]) {
let metrics: [XCTMetric] = [
XCTApplicationLaunchMetric(),
XCTClockMetric(),
XCTOSSignpostMetric(subsystem: Signposter.subsystem, category: Signposter.category, name: "\(Signposter.Name.login)"),
XCTOSSignpostMetric(subsystem: Signposter.subsystem, category: Signposter.category, name: "\(Signposter.Name.sync)"),
XCTOSSignpostMetric(subsystem: Signposter.subsystem, category: Signposter.category, name: "\(Signposter.Name.roomFlow)")
]
self.measure(metrics: metrics) {
self.runLoginLogoutFlow()
}
}
@ -47,7 +55,7 @@ class LoginTests: XCTestCase {
XCTAssertTrue(homeserverTextField.waitForExistence(timeout: 10.0))
homeserverTextField.clearAndTypeText(app.homeserver)
let confirmButton = app.buttons[A11yIdentifiers.changeServerScreen.continue]
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
confirmButton.tap()
@ -71,26 +79,27 @@ class LoginTests: XCTestCase {
XCTAssertTrue(nextButton.isEnabled)
nextButton.tap()
// Wait for login to finish
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
expectation(for: doesNotExistPredicate, evaluatedWith: nextButton)
// timeout is huge because we're waiting for server actions as well.
waitForExpectations(timeout: 300.0)
sleep(10)
// Handle save password sheet
let savePasswordButton = app.buttons["Save Password"]
if savePasswordButton.waitForExistence(timeout: 10.0) {
savePasswordButton.tap()
}
// Handle analytics prompt screen
if app.staticTexts[A11yIdentifiers.analyticsPromptScreen.title].waitForExistence(timeout: 1.0) {
// Wait for login and then handle save password sheet
let savePasswordButton = app.buttons["Save Password"]
if savePasswordButton.waitForExistence(timeout: 10.0) {
savePasswordButton.tap()
}
let enableButton = app.buttons[A11yIdentifiers.analyticsPromptScreen.enable]
XCTAssertTrue(enableButton.waitForExistence(timeout: 10.0))
enableButton.tap()
}
// This might come in a different order, wait for both.
let savePasswordButton = app.buttons["Save Password"]
if savePasswordButton.waitForExistence(timeout: 10.0) {
savePasswordButton.tap()
}
// Handle the notifications permission alert https://stackoverflow.com/a/58171074/730924
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
@ -99,9 +108,36 @@ class LoginTests: XCTestCase {
alertAllowButton.tap()
}
let profileButton = app.buttons[A11yIdentifiers.homeScreen.userAvatar]
XCTAssertTrue(profileButton.waitForExistence(timeout: 10.0))
// Migration screen may be shown as an overlay.
// if that pops up soon enough, we just let that happen and wait
let message = app.staticTexts[A11yIdentifiers.migrationScreen.message]
if message.waitForExistence(timeout: 10.0) {
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
expectation(for: doesNotExistPredicate, evaluatedWith: message)
waitForExpectations(timeout: 300.0)
}
// Welcome screen may be shown as an overlay.
if app.buttons[A11yIdentifiers.welcomeScreen.letsGo].waitForExistence(timeout: 1.0) {
let goButton = app.buttons[A11yIdentifiers.welcomeScreen.letsGo]
XCTAssertTrue(goButton.waitForExistence(timeout: 1.0))
goButton.tap()
}
// Wait for the home screen to become visible.
let profileButton = app.buttons[A11yIdentifiers.homeScreen.userAvatar]
// Timeouts are huge because we're waiting for the server.
XCTAssertTrue(profileButton.waitForExistence(timeout: 300.0))
// Open the first room in the list.
let rooms = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix))
rooms.firstMatch.tap()
// Temporary sleep to get it working.
sleep(20)
// Go back to the home screen.
app.navigationBars.firstMatch.buttons["All Chats"].tap()
// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
profileButton.forceTap()

View File

@ -27,8 +27,7 @@
"containerPath" : "container:ElementX.xcodeproj",
"identifier" : "D3DB351B7FBE0F49649171FC",
"name" : "IntegrationTests"
},
"testTimeoutsEnabled" : true
}
},
"testTargets" : [
{

View File

@ -57,3 +57,4 @@ targets:
- path: ../../ElementX/Sources/Other/AccessibilityIdentifiers.swift
- path: ../../ElementX/Sources/Other/Extensions/XCUIElement.swift
- path: ../../ElementX/Sources/Other/Extensions/NSRegularExpresion.swift
- path: ../../ElementX/Sources/Services/Analytics/Signposter.swift

View File

@ -12,8 +12,11 @@ NOW=`date -u -Iminutes`
# Find all the measurement lines in the file, then strip out the gumph into a CSV-like format.
grep ".*measured.*values" $1 | sed -e "s/.*Test Case .*-\[//" -e "s/\]' measured \[/,/" -e "s/\].*values: \[/,/" -e "s/\], performance.*//" -e "s/^/$2,/" \
-e "s/IntegrationTests.ApplicationTests testLaunchPerformance,Duration (AppLaunch), s/launchPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Clock Monotonic Time, s/loginPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Duration .AppLaunch., s/launchPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Duration .Login., s/loginPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Duration .RoomFlow., s/roomflowPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Duration .Sync., s/syncPerformance/" \
-e "s/IntegrationTests.LoginTests testLoginFlow,Clock Monotonic Time, s/totalTime/" \
-e "s/^/$NOW,/"
# The output should contain fields for the identifier, name, type, unit, then a list of recorded values (normally 5)

View File

@ -35,6 +35,7 @@ class HomeScreenViewModelTests: XCTestCase {
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: ServiceLocator.shared.settings.permalinkBaseURL),
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics,
userIndicatorController: ServiceLocator.shared.userIndicatorController)
}

View File

@ -143,15 +143,16 @@ end
lane :integration_tests do
create_simulator_if_necessary(
name: "iPhone 13 Pro",
type: "com.apple.CoreSimulator.SimDeviceType.iPhone-13-Pro"
name: "iPhone 14 Pro",
type: "com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro"
)
run_tests(
scheme: "IntegrationTests",
devices: ["iPhone 13 Pro"],
devices: ["iPhone 14 Pro"],
ensure_devices_found: true,
result_bundle: true,
reset_simulator: true,
include_simulator_logs: true
)
@ -391,7 +392,7 @@ private_lane :create_simulator_if_necessary do |options|
UI.user_error!("Invalid simulator type") unless !simulator_type.to_s.empty?
# Use use a `(` here to avoid matching `iPhone 13 Pro` on `iPhone 13 Pro Max` for example
# Use use a `(` here to avoid matching `iPhone 14 Pro` on `iPhone 14 Pro Max` for example
begin sh("xcrun simctl list devices | grep '#{simulator_name} ('")
UI.success "Simulator already exists"
rescue