1 /*
2  * Copyright (C) 2019 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 com.android.documentsui;
18 
19 import android.content.ContentProviderClient;
20 import android.database.MatrixCursor;
21 
22 import androidx.test.filters.MediumTest;
23 import androidx.test.runner.AndroidJUnit4;
24 
25 import com.android.documentsui.base.DocumentInfo;
26 
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.Mockito;
31 
32 @RunWith(AndroidJUnit4.class)
33 @MediumTest
34 public class DirectoryResultTest {
35 
36     private ContentProviderClient mClient;
37     private MatrixCursor mCursor;
38 
39     @Before
setUp()40     public void setUp() {
41         mClient = Mockito.mock(ContentProviderClient.class);
42         mCursor = Mockito.mock(MatrixCursor.class);
43     }
44 
45     @Test
testClose()46     public void testClose() {
47         DirectoryResult result = new DirectoryResult();
48         DocumentInfo doc = new DocumentInfo();
49 
50         result.client = mClient;
51         result.setCursor(mCursor);
52         result.doc = doc;
53 
54         result.close();
55 
56         Mockito.verify(mClient).close();
57         Mockito.verify(mCursor).close();
58     }
59 }
60