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();
       }

  • 相关阅读:
    emacs 配置
    .Net微服务实践(五)[服务发现]:Consul介绍和环境搭建
    .Net微服务实践(四)[网关]:Ocelot限流熔断、缓存以及负载均衡
    .Net微服务实践(三)[网关]:Ocelot配置路由和请求聚合
    .Net微服务实践(二)[网关]:Ocelot介绍和快速开始
    .Net微服务实践(一)[框架]:微服务框架选型
    研发协同平台持续集成之Jenkins实践
    统一身份认证服务IdentityServer4实践
    DevOps平台架构演进
    ABP框架
  • 原文地址:https://www.cnblogs.com/ccxniit2004/p/2314266.html
Copyright © 2011-2022 走看看