1

我正在为我的 android 应用程序编写测试用例。我的一项活动在各自的文件夹中有横向和纵向 xml 文件。我只有在横向 xml 文件中有 TextView。如何通过强制横向活动来运行我的测试用例。

我在测试用例中使用了以下代码,模拟器以横向打开并立即返回纵向模式。

Instrumentation.ActivityMonitor monitor =
            new Instrumentation.ActivityMonitor(MYActivity.class.getName(), null, false);
    getInstrumentation().addMonitor(monitor);
    // Rotate the screen
    mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getInstrumentation().waitForIdleSync();
    // Updates current activity
    mActivity = getInstrumentation().waitForMonitor(monitor);

请帮助我如何在执行我的测试用例之前保持横向。

4

0 回答 0