zoukankan      html  css  js  c++  java
  • Autotest NotePad with robotium

    1. private Solo solo;

       public NotePadTest() {
        super("com.example.android.notepad", NotesList.class);
        
       }
       
        public void setUp() throws Exception {
         solo = new Solo(getInstrumentation(), getActivity());
          }

       
        @Smoke
        public void testAddNote() throws Exception {
         solo.clickOnMenuItem("Add note");
         solo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor"); //Assert that NoteEditor activity is opened
         solo.enterText(0, "Note 1"); //In text field 0, add Note 1
         solo.goBack(); //Go back
         solo.clickOnMenuItem("Add note"); //Clicks on menu item
         solo.enterText(0, "Note 2"); //In text field 0, add Note 2
         solo.goBackToActivity("NotesList"); //Go back to first activity named "NotesList"
         boolean expected = true;
         boolean actual = solo.searchText("Note 1") && solo.searchText("Note 2");
         assertEquals("Note 1 and/or Note 2 are not found", expected, actual); //Assert that Note 1 & Note 2 are found
        
        }
       
       @Smoke
       public void testEditNote() throws Exception {
        solo.clickInList(2); // Clicks on the second list line
        solo.setActivityOrientation(Solo.LANDSCAPE); // Change orientation of activity
        solo.clickOnMenuItem("Edit title"); // Change title
        solo.enterText(0, " test"); //In first text field (0), add test.
        solo.goBackToActivity("NotesList");
        boolean expected = true;
        boolean actual = solo.searchText("(?i).*?note 1 test"); // (Regexp) case insensitive            // insensitive
        assertEquals("Note 1 test is not found", expected, actual); //Assert that Note 1 test is found

       }
       

       @Smoke
        public void testRemoveNote() throws Exception {
         solo.clickOnText("(?i).*?test.*");   //(Regexp) case insensitive/text that contains "test"
         solo.clickOnMenuItem("Delete");   //Delete Note 1 test
         boolean expected = false;   //Note 1 test & Note 2 should not be found
         boolean actual = solo.searchText("Note 1 test");
         assertEquals("Note 1 Test is found", expected, actual);  //Assert that Note 1 test is not found
         solo.clickLongOnText("Note 2");
         solo.clickOnText("(?i).*?Delete.*");  //Clicks on Delete in the context menu
         actual = solo.searchText("Note 2");
         assertEquals("Note 2 is found", expected, actual);  //Assert that Note 2 is not found
        }

       @Override
       public void tearDown() throws Exception {
        try {
         solo.finalize();  //Robotium will finish all the activities that have been open
        } catch (Throwable e) {
         e.printStackTrace();
        }
        getActivity().finish();
        super.tearDown();
       }

  • 相关阅读:
    Jenkins参数化构建
    python笔记
    jenkins定时任务
    技巧:Vimdiff 使用
    clover如何使用UEFI引导和EFI驱动选择
    Broadcast BCM94322 用ubuntu修改ID
    MAC实现睡眠和休眠唤醒
    MAC的睡眠模式介绍
    linux 用dd命令读写引导区文件
    MAC下打开FTP服务
  • 原文地址:https://www.cnblogs.com/ccxniit2004/p/2314266.html
Copyright © 2011-2022 走看看