appium / WebDriverAgent

A WebDriver server for iOS and tvOS
Other
1.18k stars 368 forks source link

feat: Add an API to simulate the Low Memory warning #833

Closed mykola-mokhnach closed 7 months ago

mykola-mokhnach commented 8 months ago

https://stackoverflow.com/questions/4717138/ios-development-how-can-i-induce-low-memory-warnings-on-device

mykola-mokhnach commented 8 months ago

@KazuCocoa @Dan-Maor Could you please test this API with a real app that actually has the didReceiveMemoryWarning defined?

Dan-Maor commented 8 months ago

I will give it a test tomorrow. Are you sure this selector will simulate the memory warning on the app under test? From what I remember [UIApplication sharedApplication] is the currently executed application, in this case it will be WebDriverAgent itself.

mykola-mokhnach commented 8 months ago

I will give it a test tomorrow. Are you sure this selector will simulate the memory warning on the app under test? From what I remember [UIApplication sharedApplication] is the currently executed application, in this case it will be WebDriverAgent itself.

I expect WDA to be in background, so sharedApplication returns the currently running/foreground app. This assumption needs to be confirmed though.

KazuCocoa commented 8 months ago

It will take more time to test. I'll test with tvOS as well. (will create a simple app with didReceiveMemoryWarning and to test, maybe can be done in this week)

Dan-Maor commented 8 months ago

According to the documentation, [UIApplication sharedApplication] is tied to the executing application's UIApplicationMain, so it doesn't look like it's related to the application in the foreground. https://developer.apple.com/documentation/uikit/uiapplication/1622975-sharedapplication I've confirmed it by invoking applicationState on the object, and the returned state is UIApplicationStateBackground, meaning it is tied to the executing application (WDA) as I've suspected.

I wrote a quick app which handles applicationDidReceiveMemoryWarning by just printing a log line, however calling the WDA command doesn't look like it has any effect on the app as the function is not invoked.

mykola-mokhnach commented 7 months ago

@Dan-Maor Thanks for checking it. I will try a different approach then