【问题标题】:How to trigger the same action on 3 android emulators and 1 iOS emulator at the same time?如何同时在 3 个 android 模拟器和 1 个 iOS 模拟器上触发相同的操作?
【发布时间】:2017-04-17 11:53:40
【问题描述】:

目前我正在尝试建立一个用于研究目的的测试环境。我想要实现的是以下情况: 我想在我的 macbook 上使用模拟器运行 3 个 Android 应用程序和 1 个 iOS 应用程序。它们是具有相似 UI 的应用程序,但背后的代码不同。我想同时在所有模拟器上启动相同的操作,比如按下按钮或调用方法。

我已经尝试在模拟器上运行应用程序并让它们在 Firebase 上的实时数据库中监听变化的值,所以每次我在 Firebase 中更改值时,所有应用程序都会调用该方法。这种设置的问题是应用之间的延迟,因为它们依赖于稳定的互联网连接。

是否有任何其他解决方案可以同时触发所有模拟器上的操作?非常感谢您的帮助!

谢谢

根据答案和 cmets 进行编辑: - 我想在我想在应用程序上运行操作时进行选择。这意味着例如警报管理器是一个不太可取的解决方案。 - 我想避免外部网络调用。

【问题讨论】:

    标签: android ios user-interface automated-tests emulation


    【解决方案1】:

    1)尝试使用 GCM/FCM 并将命令从服务器发送到所有模拟器/设备并调用该 GCM 命令上的方法。

    2) 使用闹钟管理器为特定时间设置闹钟并在该时间调用方法。

    【讨论】:

    • 感谢您的回答,非常感谢! GCM/FCM不是也依赖稳定的网络吗?而且我喜欢警报管理器解决方案,但我想随时调用应用程序上的操作,而不是在固定的时间...
    【解决方案2】:

    您可以在 Android 中使用 AlarmManager 实现此目的。

    它将在 18:32 运行(将时间设置为未来并在 3 个 android 模拟器上运行代码,确保所有设备具有相同的时间)

    Calendar cur_cal = new GregorianCalendar();
    cur_cal.setTimeInMillis(System.currentTimeMillis());//set the current time and date for this calendar
    
    Calendar cal = new GregorianCalendar();
    cal.add(Calendar.DAY_OF_YEAR, cur_cal.get(Calendar.DAY_OF_YEAR));
    cal.set(Calendar.HOUR_OF_DAY, 18);
    cal.set(Calendar.MINUTE, 32);
    cal.set(Calendar.SECOND, cur_cal.get(Calendar.SECOND));
    cal.set(Calendar.MILLISECOND, cur_cal.get(Calendar.MILLISECOND));
    cal.set(Calendar.DATE, cur_cal.get(Calendar.DATE));
    cal.set(Calendar.MONTH, cur_cal.get(Calendar.MONTH));
    Intent intent = new Intent(ProfileList.this, IntentBroadcastedReceiver.class);
    PendingIntent pintent = PendingIntent.getService(ProfileList.this, 0, intent, 0);
    AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    alarm.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pintent);
    

    【讨论】:

    • 感谢您的回答,非常感谢!我喜欢警报管理器解决方案,但我想随时调用应用程序上的操作,而不是按固定时间...
    猜你喜欢
    • 2018-02-21
    • 2017-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-30
    • 2022-09-26
    • 2013-08-29
    • 1970-01-01
    相关资源
    最近更新 更多