2 * Copyright (C) 2009 The Android Open Source Project
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 package com.android.sdklib.internal.repository;
\r
19 import com.android.sdklib.AndroidVersion;
\r
20 import com.android.sdklib.IAndroidTarget;
\r
23 * A mock {@link AddonPackage} for testing.
\r
25 * By design, this package contains one and only one archive.
\r
27 public class MockAddonPackage extends AddonPackage {
\r
30 * Creates a {@link MockAddonTarget} with the requested base platform and addon revision
\r
31 * and then a {@link MockAddonPackage} wrapping it.
\r
33 * By design, this package contains one and only one archive.
\r
35 public MockAddonPackage(MockPlatformPackage basePlatform, int revision) {
\r
36 super(new MockAddonTarget(basePlatform.getTarget(), revision), null /*props*/);
\r
40 * A mock AddonTarget.
\r
41 * This reimplements the minimum needed from the interface for our limited testing needs.
\r
43 static class MockAddonTarget implements IAndroidTarget {
\r
45 private final IAndroidTarget mParentTarget;
\r
46 private final int mRevision;
\r
48 public MockAddonTarget(IAndroidTarget parentTarget, int revision) {
\r
49 mParentTarget = parentTarget;
\r
50 mRevision = revision;
\r
53 public String getClasspathName() {
\r
57 public String getDefaultSkin() {
\r
61 public String getDescription() {
\r
62 return "mock addon target";
\r
65 public String getFullName() {
\r
66 return "mock addon target";
\r
69 public String getLocation() {
\r
73 public String getName() {
\r
74 return "mock addon target";
\r
77 public IOptionalLibrary[] getOptionalLibraries() {
\r
81 public IAndroidTarget getParent() {
\r
82 return mParentTarget;
\r
85 public String getPath(int pathId) {
\r
89 public String[] getPlatformLibraries() {
\r
93 public int getRevision() {
\r
97 public String[] getSkins() {
\r
101 public int getUsbVendorId() {
\r
105 public String getVendor() {
\r
109 public AndroidVersion getVersion() {
\r
110 return mParentTarget.getVersion();
\r
113 public String getVersionName() {
\r
114 return String.format("mock-addon-%1$d", getVersion().getApiLevel());
\r
117 public String hashString() {
\r
118 return getVersionName();
\r
121 /** Returns false for an addon. */
\r
122 public boolean isPlatform() {
\r
126 public boolean isCompatibleBaseFor(IAndroidTarget target) {
\r
127 throw new UnsupportedOperationException("Implement this as needed for tests");
\r
130 public int compareTo(IAndroidTarget o) {
\r
131 throw new UnsupportedOperationException("Implement this as needed for tests");
\r