OSDN Git Service

android-2.1_r1 snapshot
[android-x86/sdk.git] / sdkmanager / libs / sdklib / tests / com / android / sdklib / internal / repository / MockAddonPackage.java
1 /*\r
2  * Copyright (C) 2009 The Android Open Source Project\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 package com.android.sdklib.internal.repository;\r
18 \r
19 import com.android.sdklib.AndroidVersion;\r
20 import com.android.sdklib.IAndroidTarget;\r
21 \r
22 /**\r
23  * A mock {@link AddonPackage} for testing.\r
24  *\r
25  * By design, this package contains one and only one archive.\r
26  */\r
27 public class MockAddonPackage extends AddonPackage {\r
28 \r
29     /**\r
30      * Creates a {@link MockAddonTarget} with the requested base platform and addon revision\r
31      * and then a {@link MockAddonPackage} wrapping it.\r
32      *\r
33      * By design, this package contains one and only one archive.\r
34      */\r
35     public MockAddonPackage(MockPlatformPackage basePlatform, int revision) {\r
36         super(new MockAddonTarget(basePlatform.getTarget(), revision), null /*props*/);\r
37     }\r
38 \r
39     /**\r
40      * A mock AddonTarget.\r
41      * This reimplements the minimum needed from the interface for our limited testing needs.\r
42      */\r
43     static class MockAddonTarget implements IAndroidTarget {\r
44 \r
45         private final IAndroidTarget mParentTarget;\r
46         private final int mRevision;\r
47 \r
48         public MockAddonTarget(IAndroidTarget parentTarget, int revision) {\r
49             mParentTarget = parentTarget;\r
50             mRevision = revision;\r
51         }\r
52 \r
53         public String getClasspathName() {\r
54             return null;\r
55         }\r
56 \r
57         public String getDefaultSkin() {\r
58             return null;\r
59         }\r
60 \r
61         public String getDescription() {\r
62             return "mock addon target";\r
63         }\r
64 \r
65         public String getFullName() {\r
66             return "mock addon target";\r
67         }\r
68 \r
69         public String getLocation() {\r
70             return "";\r
71         }\r
72 \r
73         public String getName() {\r
74             return "mock addon target";\r
75         }\r
76 \r
77         public IOptionalLibrary[] getOptionalLibraries() {\r
78             return null;\r
79         }\r
80 \r
81         public IAndroidTarget getParent() {\r
82             return mParentTarget;\r
83         }\r
84 \r
85         public String getPath(int pathId) {\r
86             return null;\r
87         }\r
88 \r
89         public String[] getPlatformLibraries() {\r
90             return null;\r
91         }\r
92 \r
93         public int getRevision() {\r
94             return mRevision;\r
95         }\r
96 \r
97         public String[] getSkins() {\r
98             return null;\r
99         }\r
100 \r
101         public int getUsbVendorId() {\r
102             return 0;\r
103         }\r
104 \r
105         public String getVendor() {\r
106             return null;\r
107         }\r
108 \r
109         public AndroidVersion getVersion() {\r
110             return mParentTarget.getVersion();\r
111         }\r
112 \r
113         public String getVersionName() {\r
114             return String.format("mock-addon-%1$d", getVersion().getApiLevel());\r
115         }\r
116 \r
117         public String hashString() {\r
118             return getVersionName();\r
119         }\r
120 \r
121         /** Returns false for an addon. */\r
122         public boolean isPlatform() {\r
123             return false;\r
124         }\r
125 \r
126         public boolean isCompatibleBaseFor(IAndroidTarget target) {\r
127             throw new UnsupportedOperationException("Implement this as needed for tests");\r
128         }\r
129 \r
130         public int compareTo(IAndroidTarget o) {\r
131             throw new UnsupportedOperationException("Implement this as needed for tests");\r
132         }\r
133 \r
134     }\r
135 \r
136 }\r