1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony.mbms;
18 
19 import static org.junit.Assert.assertEquals;
20 
21 import android.test.suitebuilder.annotation.SmallTest;
22 
23 import androidx.test.runner.AndroidJUnit4;
24 
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 
28 @RunWith(AndroidJUnit4.class)
29 public class MbmsReceiverTest {
30     @Test
31     @SmallTest
testFileHierarchyRecreation()32     public void testFileHierarchyRecreation() throws Exception {
33         String rootPath = "http://www.example.com/files/";
34         assertEquals("subdir1/file.txt",
35                 MbmsDownloadReceiver.getFileRelativePath(rootPath, rootPath + "/subdir1/file.txt"));
36         assertEquals("subdir1/subdir2/file.txt",
37                 MbmsDownloadReceiver.getFileRelativePath(
38                         rootPath,
39                         rootPath + "/subdir1/subdir2/file.txt"));
40         assertEquals("file.txt",
41                 MbmsDownloadReceiver.getFileRelativePath(
42                         rootPath + "/subdir1/file.*",
43                         rootPath + "/subdir1/file.txt"));
44         assertEquals("file.txt",
45                 MbmsDownloadReceiver.getFileRelativePath(
46                         rootPath + "/subdir1/*",
47                         rootPath + "/subdir1/file.txt"));
48         assertEquals("subdir1/file.txt",
49                 MbmsDownloadReceiver.getFileRelativePath(
50                         rootPath + "/subdir*",
51                         rootPath + "/subdir1/file.txt"));
52         assertEquals("file.txt",
53                 MbmsDownloadReceiver.getFileRelativePath(
54                         rootPath,
55                         rootPath + "/file.txt"));
56         assertEquals("file.txt",
57                 MbmsDownloadReceiver.getFileRelativePath(
58                         rootPath + "/*",
59                         rootPath + "/file.txt"));
60     }
61 }
62