1/*
2 * Copyright (C) 2010 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
17package com.android.gallery3d.data;
18
19import com.android.gallery3d.app.GalleryApp;
20
21import android.test.AndroidTestCase;
22import android.test.suitebuilder.annotation.SmallTest;
23
24public class MediaSetTest extends AndroidTestCase {
25    @SuppressWarnings("unused")
26    private static final String TAG = "MediaSetTest";
27
28    @SmallTest
29    public void testComboAlbumSet() {
30        GalleryApp app = new GalleryAppMock(null, null, null);
31        Path.clearAll();
32        DataManager dataManager = app.getDataManager();
33
34        dataManager.addSource(new ComboSource(app));
35        dataManager.addSource(new MockSource(app));
36
37        MockSet set00 = new MockSet(Path.fromString("/mock/00"), dataManager, 0, 2000);
38        MockSet set01 = new MockSet(Path.fromString("/mock/01"), dataManager, 1, 3000);
39        MockSet set10 = new MockSet(Path.fromString("/mock/10"), dataManager, 2, 4000);
40        MockSet set11 = new MockSet(Path.fromString("/mock/11"), dataManager, 3, 5000);
41        MockSet set12 = new MockSet(Path.fromString("/mock/12"), dataManager, 4, 6000);
42
43        MockSet set0 = new MockSet(Path.fromString("/mock/0"), dataManager, 7, 7000);
44        set0.addMediaSet(set00);
45        set0.addMediaSet(set01);
46
47        MockSet set1 = new MockSet(Path.fromString("/mock/1"), dataManager, 8, 8000);
48        set1.addMediaSet(set10);
49        set1.addMediaSet(set11);
50        set1.addMediaSet(set12);
51
52        MediaSet combo = dataManager.getMediaSet("/combo/{/mock/0,/mock/1}");
53        assertEquals(5, combo.getSubMediaSetCount());
54        assertEquals(0, combo.getMediaItemCount());
55        assertEquals("/mock/00", combo.getSubMediaSet(0).getPath().toString());
56        assertEquals("/mock/01", combo.getSubMediaSet(1).getPath().toString());
57        assertEquals("/mock/10", combo.getSubMediaSet(2).getPath().toString());
58        assertEquals("/mock/11", combo.getSubMediaSet(3).getPath().toString());
59        assertEquals("/mock/12", combo.getSubMediaSet(4).getPath().toString());
60
61        assertEquals(10, combo.getTotalMediaItemCount());
62    }
63}
64