Try to fix intermittent iOS test failures
This commit is contained in:
Родитель
4cfefee799
Коммит
4d28bb62f0
|
@ -130,11 +130,11 @@ class FxAccountManagerTests: XCTestCase {
|
|||
func testAccountNotFound() {
|
||||
let mgr = mockFxAManager()
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
let account = mgr.account as! MockFxAccount
|
||||
let constellation = mgr.constellation as! MockDeviceConstellation
|
||||
|
@ -151,11 +151,10 @@ class FxAccountManagerTests: XCTestCase {
|
|||
expectation(forNotification: .accountAuthenticated, object: nil, handler: nil)
|
||||
expectation(forNotification: .accountProfileUpdate, object: nil, handler: nil)
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
// Fetch devices is run async, so it could happen after getProfile, hence we don't do a strict
|
||||
|
@ -184,11 +183,10 @@ class FxAccountManagerTests: XCTestCase {
|
|||
expectation(forNotification: .accountAuthenticated, object: nil, handler: nil)
|
||||
expectation(forNotification: .accountProfileUpdate, object: nil, handler: nil)
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
XCTAssertTrue(account.invocations.contains(MockFxAccount.MethodInvocation.registerPersistCallback))
|
||||
|
@ -221,11 +219,10 @@ class FxAccountManagerTests: XCTestCase {
|
|||
expectation(forNotification: .accountProfileUpdate, object: nil, handler: nil)
|
||||
expectation(forNotification: .accountAuthProblems, object: nil, handler: nil)
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
XCTAssertTrue(mgr.accountNeedsReauth())
|
||||
|
@ -243,7 +240,7 @@ class FxAccountManagerTests: XCTestCase {
|
|||
|
||||
func testNewAccountLogIn() {
|
||||
let mgr = mockFxAManager()
|
||||
let beginAuthDone = XCTestExpectation(description: "beginAuthDone")
|
||||
let beginAuthDone = expectation(description: "beginAuthDone")
|
||||
var authURL: String?
|
||||
mgr.initialize { _ in
|
||||
mgr.beginAuthentication { url in
|
||||
|
@ -251,16 +248,16 @@ class FxAccountManagerTests: XCTestCase {
|
|||
beginAuthDone.fulfill()
|
||||
}
|
||||
}
|
||||
wait(for: [beginAuthDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
XCTAssertEqual(authURL, "https://foo.bar/oauth?state=bobo")
|
||||
|
||||
let finishAuthDone = XCTestExpectation(description: "finishAuthDone")
|
||||
let finishAuthDone = expectation(description: "finishAuthDone")
|
||||
mgr.finishAuthentication(authData: FxaAuthData(code: "bobo", state: "bobo", actionQueryParam: "email")) { result in
|
||||
if case .success = result {
|
||||
finishAuthDone.fulfill()
|
||||
}
|
||||
}
|
||||
wait(for: [finishAuthDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
let account = mgr.account! as! MockFxAccount
|
||||
XCTAssertTrue(account.invocations.contains(MockFxAccount.MethodInvocation.registerPersistCallback))
|
||||
|
@ -276,7 +273,7 @@ class FxAccountManagerTests: XCTestCase {
|
|||
|
||||
func testAuthStateVerification() {
|
||||
let mgr = mockFxAManager()
|
||||
let beginAuthDone = XCTestExpectation(description: "beginAuthDone")
|
||||
let beginAuthDone = expectation(description: "beginAuthDone")
|
||||
var authURL: String?
|
||||
mgr.initialize { _ in
|
||||
mgr.beginAuthentication { url in
|
||||
|
@ -284,16 +281,16 @@ class FxAccountManagerTests: XCTestCase {
|
|||
beginAuthDone.fulfill()
|
||||
}
|
||||
}
|
||||
wait(for: [beginAuthDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
XCTAssertEqual(authURL, "https://foo.bar/oauth?state=bobo")
|
||||
|
||||
let finishAuthDone = XCTestExpectation(description: "finishAuthDone")
|
||||
let finishAuthDone = expectation(description: "finishAuthDone")
|
||||
mgr.finishAuthentication(authData: FxaAuthData(code: "bobo", state: "NOTBOBO", actionQueryParam: "email")) { result in
|
||||
if case .failure = result {
|
||||
finishAuthDone.fulfill()
|
||||
}
|
||||
}
|
||||
wait(for: [finishAuthDone], timeout: 5)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
}
|
||||
|
||||
func testProfileRecoverableAuthError() {
|
||||
|
@ -317,12 +314,11 @@ class FxAccountManagerTests: XCTestCase {
|
|||
expectation(forNotification: .accountAuthenticated, object: nil, handler: nil)
|
||||
expectation(forNotification: .accountProfileUpdate, object: nil, handler: nil)
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 5)
|
||||
waitForExpectations(timeout: 10, handler: nil)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
XCTAssertFalse(mgr.accountNeedsReauth())
|
||||
|
||||
|
@ -339,13 +335,13 @@ class FxAccountManagerTests: XCTestCase {
|
|||
let account = MockAccount()
|
||||
mgr.storedAccount = account
|
||||
|
||||
let initDone = XCTestExpectation(description: "Initialization done")
|
||||
let initDone = expectation(description: "Initialization done")
|
||||
mgr.initialize { _ in
|
||||
initDone.fulfill()
|
||||
}
|
||||
wait(for: [initDone], timeout: 10)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
let tokenServerURLCorrect = XCTestExpectation(description: "Server URL is correct")
|
||||
let tokenServerURLCorrect = expectation(description: "Server URL is correct")
|
||||
mgr.getTokenServerEndpointURL { url in
|
||||
XCTAssertEqual(
|
||||
try! url.get().absoluteString,
|
||||
|
@ -353,6 +349,6 @@ class FxAccountManagerTests: XCTestCase {
|
|||
)
|
||||
tokenServerURLCorrect.fulfill()
|
||||
}
|
||||
wait(for: [tokenServerURLCorrect], timeout: 10)
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@ class MockFxAccount: FxAccount {
|
|||
fatalError("init(config:) has not been implemented")
|
||||
}
|
||||
|
||||
override func isInMigrationState() -> Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
override func initializeDevice(name _: String, deviceType _: DeviceType, supportedCapabilities _: [DeviceCapability]) throws {
|
||||
invocations.append(.initializeDevice)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче