Coverage for example/example_mainpath_property.py: 67%

30 statements  

« prev     ^ index     » next       coverage.py v7.6.9, created at 2024-12-22 16:05 +0800

1import random 

2from kea import * 

3 

4class Test(KeaTest): 

5 

6 @initializer() 

7 def set_up(self): 

8 if d(text="Allow").exists(): 

9 d(text="Allow").click() 

10 

11 for _ in range(5): 

12 d(resourceId="it.feio.android.omninotes.alpha:id/next").click() 

13 d(resourceId="it.feio.android.omninotes.alpha:id/done").click() 

14 

15 @mainPath() 

16 def test_main(self): 

17 d(resourceId="it.feio.android.omninotes.alpha:id/fab_expand_menu_button").long_click() 

18 d(resourceId="it.feio.android.omninotes.alpha:id/detail_content").click() 

19 d(resourceId="it.feio.android.omninotes.alpha:id/detail_content").set_text("read a book #Tag1") 

20 d(description="drawer open").click() 

21 d(resourceId="it.feio.android.omninotes.alpha:id/note_content").click() 

22 

23 @precondition(lambda self: d(resourceId="it.feio.android.omninotes.alpha:id/menu_tag").exists() and 

24 "#" in d(resourceId="it.feio.android.omninotes.alpha:id/detail_content").info["text"]) 

25 @rule() 

26 def rule_remove_tag_from_note_shouldnot_affect_content(self): 

27 import random 

28 # get the text from the note's content 

29 origin_content = d(resourceId="it.feio.android.omninotes.alpha:id/detail_content").info["text"] 

30 # click to open the tag list 

31 d(resourceId="it.feio.android.omninotes.alpha:id/menu_tag").click() 

32 # select a tag to remove 

33 selected_tag = random.choice(d(className="android.widget.CheckBox", checked=True)) 

34 select_tag_name = "#" + selected_tag.right(resourceId="it.feio.android.omninotes.alpha:id/md_title").info["text"].split( " ")[0] 

35 selected_tag.click() 

36 # click to uncheck the selected tag 

37 d(text="OK").click() 

38 # get the updated content after removing the tag 

39 new_content = d(resourceId="it.feio.android.omninotes.alpha:id/detail_content").info["text"].strip().replace("Content", "") 

40 # get the expected content after removing the tag 

41 origin_content_exlude_tag = origin_content.replace(select_tag_name, "").strip() 

42 # the tag should be removed in the content and the updated content should be the same as the expected content 

43 assert not d(textContains=select_tag_name).exists() and new_content == origin_content_exlude_tag