OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 ## Include utility functions. |
| 4 . "$XDG_TEST_DIR/include/testassertions.sh" |
| 5 . "$XDG_TEST_DIR/include/testcontrol.sh" |
| 6 |
| 7 ## Test function |
| 8 test_user_mime_install2in1() { |
| 9 |
| 10 ## Begin the test. |
| 11 test_start "$FUNCNAME: install user mime type 2 in 1 file" |
| 12 test_purpose "Verify that new mime types get installed into the user space corre
ctly when they are in the same file" |
| 13 |
| 14 # Dependencies section |
| 15 test_init |
| 16 |
| 17 require_notroot |
| 18 |
| 19 use_file "$XDG_TEST_DIR/xdg-mime/data/test2mime.xml" INPUT_FILE |
| 20 edit_file "$INPUT_FILE" "x-xdg-testpattern" TEST1_MIME "x-xdg-01-$XDG_TEST_ID" |
| 21 edit_file "$INPUT_FILE" "x-xdg-test2pattern" TEST2_MIME "x-xdg-02-$XDG_TEST_ID" |
| 22 |
| 23 assert_file "$INPUT_FILE" |
| 24 echo "text/$TEST1_MIME" >out.expect1 |
| 25 echo "text/$TEST2_MIME" >out.expect2 |
| 26 |
| 27 echo "Some text." >testfile.xdg1test |
| 28 echo "Some text." >testfile.xdg2test |
| 29 assert_file testfile.xdg1test |
| 30 assert_file testfile.xdg2test |
| 31 |
| 32 |
| 33 # Verify the test type is not installed already. |
| 34 assert_exit 0 xdg-mime query filetype testfile.xdg1test |
| 35 assert_stdout |
| 36 mv out.stdout out.save1 |
| 37 assert_exit 1 diff out.save1 out.expect1 |
| 38 |
| 39 # Test steps section |
| 40 test_procedure |
| 41 |
| 42 assert_exit 0 xdg-mime install --mode user "$INPUT_FILE" |
| 43 assert_nostdout |
| 44 assert_nostderr |
| 45 |
| 46 sleep 1 |
| 47 |
| 48 assert_exit 0 xdg-mime query filetype testfile.xdg1test |
| 49 assert_stdout out.expect1 |
| 50 assert_nostderr |
| 51 |
| 52 assert_exit 0 xdg-mime query filetype testfile.xdg2test |
| 53 assert_stdout out.expect2 |
| 54 assert_nostderr |
| 55 |
| 56 # Cleanup |
| 57 xdg-mime uninstall --mode user "$INPUT_FILE" >/dev/null 2>&1 |
| 58 |
| 59 test_result |
| 60 } |
| 61 run_test test_user_mime_install2in1 |
OLD | NEW |