gpt4 book ai didi

ios - 背景图像在 UTesting 期间导致内存警告和崩溃

转载 作者:行者123 更新时间:2023-11-30 13:51:29 24 4
gpt4 key购买 nike

我有一个简单的 UITest,它点击工具栏上的某个项目 100 次,在没有背景图像的情况下运行测试始终通过,但是当我添加背景图像时,我收到内存警告,然后测试失败。我尝试了多种显示图像的解决方案,大多数都会导致相同的结果,内存警告,然后崩溃。我有一个图像集,由三个 png 图像组成,尺寸分别为 3X: 2304 X 3072、2X: 1536 X 2048 和 1X: 768 X 1024,根据苹果文档。如何添加背景图像以免导致内存问题。

UI测试代码:

func testJustNumberOfRolls() {
let app = XCUIApplication()
for _ in 1...100 {
app.toolbars.buttons["Tip2"].tap()
}
}

View Controller :

class TestVC: UIViewController {    

override func viewDidLoad() {
super.viewDidLoad()
if let image = UIImage(named: "feltSized") {
self.view.backgroundColor = UIColor(patternImage: image)
}
}
}

测试日志:

11:10:49.317 XCTRunner[6768:2874277] -[TestingUIActual 

testJustNumberOfRolls] started activity <XCActivityRecord: 0x1314a5ab0> 2015-12-11 17:10:49 +0000: Wait for app to idle
11:10:49.528 XCTRunner[6768:2874277] Waiting for app quiescence...
11:10:49.529 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:49.529 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:49.530 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:49.531 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:49.535 XCTRunner[6768:2874320] Got AX notification 4002
11:10:49.536 XCTRunner[6768:2874320] Got animations reply.
11:10:49.536 XCTRunner[6768:2874320] Animations are not active.
11:10:49.537 XCTRunner[6768:2874320] Got AX notification 4002
11:10:49.537 XCTRunner[6768:2874322] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:49.538 XCTRunner[6768:2874320] Got event loop idle reply.
11:10:49.539 XCTRunner[6768:2874320] Event loop is idle.
11:10:49.538 XCTRunner[6768:2874322] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:49.540 XCTRunner[6768:2874322] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:49.541 XCTRunner[6768:2874322] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:49.542 XCTRunner[6768:2874277] App has quiesced.
11:10:49.542 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x1314a5ab0> 2015-12-11 17:10:49 +0000: Wait for app to idle (0.225394s)
11:10:49.550 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x1314a2970> 2015-12-11 17:10:49 +0000: Find the "Tip2" Button (0.298589s)
11:10:49.553 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] started activity <XCActivityRecord: 0x1314abf80> 2015-12-11 17:10:49 +0000: Synthesize event
11:10:49.966 XCTRunner[6768:2874320] Got AX notification 4002
11:10:49.967 XCTRunner[6768:2874320] Got event completion.
11:10:49.969 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x1314abf80> 2015-12-11 17:10:49 +0000: Synthesize event (0.416638s)
11:10:49.973 XCTRunner[6768:2874320] Got AX notification 4002
11:10:49.988 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] started activity <XCActivityRecord: 0x1315415e0> 2015-12-11 17:10:49 +0000: Wait for app to idle
11:10:50.197 XCTRunner[6768:2874277] Waiting for app quiescence...
11:10:50.198 XCTRunner[6768:2874358] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:50.198 XCTRunner[6768:2874358] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:50.199 XCTRunner[6768:2874358] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:50.200 XCTRunner[6768:2874358] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:50.204 XCTRunner[6768:2874358] Got AX notification 4002
11:10:50.204 XCTRunner[6768:2874358] Got event loop idle reply.
11:10:50.205 XCTRunner[6768:2874358] Event loop is idle.
11:10:50.205 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:50.206 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:50.437 XCTRunner[6768:2874358] Got AX notification 4002
11:10:50.438 XCTRunner[6768:2874358] Got animations reply.
11:10:50.442 XCTRunner[6768:2874358] Animations are not active.
11:10:50.443 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:50.444 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:50.446 XCTRunner[6768:2874277] App has quiesced.
11:10:50.447 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x1315415e0> 2015-12-11 17:10:49 +0000: Wait for app to idle (0.459272s)
11:10:50.460 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x13149e5f0> 2015-12-11 17:10:49 +0000: Tap "Tip2" Button (1.4335s)
11:10:50.464 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] started activity <XCActivityRecord: 0x1314af0f0> 2015-12-11 17:10:50 +0000: Tap "Tip2" Button
11:10:50.466 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] started activity <XCActivityRecord: 0x131544810> 2015-12-11 17:10:50 +0000: Wait for app to idle
11:10:50.669 XCTRunner[6768:2874277] Waiting for app quiescence...
11:10:50.669 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:50.670 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:50.670 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 1 -> 0
11:10:50.671 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 1 -> 0
11:10:50.676 XCTRunner[6768:2874356] Got AX notification 4002
11:10:50.676 XCTRunner[6768:2874356] Got animations reply.
11:10:50.677 XCTRunner[6768:2874356] Animations are not active.
11:10:50.677 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:50.677 XCTRunner[6768:2874567] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:50.679 XCTRunner[6768:2874320] Got AX notification 4002
11:10:50.679 XCTRunner[6768:2874320] Got event loop idle reply.
11:10:50.680 XCTRunner[6768:2874320] Event loop is idle.
11:10:50.680 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> hasReceivedAnimationsHaveFinished 0 -> 1
11:10:50.681 XCTRunner[6768:2874357] <XCUIApplicationProcess: 0x12fe466a0 mikepland.crapsBuzzInSwift (6775)> event loop is idle 0 -> 1
11:10:50.682 XCTRunner[6768:2874277] App has quiesced.
11:10:50.682 XCTRunner[6768:2874277] -[TestingUIActual testJustNumberOfRolls] finished activity <XCActivityRecord: 0x131544810> 2015-12-11 17:10:50 +0000: Wait for app to idle (0.216641s)
11:10:50.718 Xcode[1265:207640] Test operation failure: Lost connection to test manager service.
11:10:50.719 Xcode[1265:207640] _finishWithError:Error Domain=IDETestOperationsObserverErrorDomain Code=4 "Lost connection to test manager service." UserInfo={NSLocalizedDescription=Lost connection to test manager service.} didCancel: 1

最佳答案

更新:我尝试不显示任何图像,这似乎更好。错误显示为“与测试管理器服务的连接丢失”。

此时,我已经重构了我的应用程序以避免长动画,从而避免测试需要超时,然后重新编码应用程序以隐藏所有图像和背景颜色。即使如此,尽管测试可以运行更长时间,但错误仍然会出现。

我能够在一个全新的应用程序上进行复制,只需一个背景图案和一个按钮,即使运行测试超过几分钟也会导致错误,这就是一个全新的应用程序。所以我不知道还能做什么,希望这个问题能很快得到解决。

关于ios - 背景图像在 UTesting 期间导致内存警告和崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34229202/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com