auto import from //depot/cupcake/@135843
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unittests"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
29
tools/eclipse/plugins/com.android.ide.eclipse.tests/.project
Normal file
29
tools/eclipse/plugins/com.android.ide.eclipse.tests/.project
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>adt-tests</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>SdkLib</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,19 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Android Plugin Tests
|
||||
Bundle-SymbolicName: com.android.ide.eclipse.tests
|
||||
Bundle-Version: 0.9.0.qualifier
|
||||
Bundle-Activator: com.android.ide.eclipse.tests.AndroidTestPlugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources,
|
||||
com.android.ide.eclipse.adt,
|
||||
org.junit,
|
||||
org.eclipse.jdt.core,
|
||||
org.eclipse.jdt.launching,
|
||||
org.eclipse.ui.views,
|
||||
com.android.ide.eclipse.ddms
|
||||
Eclipse-LazyStart: true
|
||||
Bundle-Vendor: The Android Open Source Project
|
||||
Bundle-ClassPath: kxml2-2.3.0.jar,
|
||||
.
|
||||
224
tools/eclipse/plugins/com.android.ide.eclipse.tests/NOTICE
Normal file
224
tools/eclipse/plugins/com.android.ide.eclipse.tests/NOTICE
Normal file
@@ -0,0 +1,224 @@
|
||||
*Eclipse Public License - v 1.0*
|
||||
|
||||
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
|
||||
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
|
||||
THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
|
||||
|
||||
*1. DEFINITIONS*
|
||||
|
||||
"Contribution" means:
|
||||
|
||||
a) in the case of the initial Contributor, the initial code and
|
||||
documentation distributed under this Agreement, and
|
||||
b) in the case of each subsequent Contributor:
|
||||
|
||||
i) changes to the Program, and
|
||||
|
||||
ii) additions to the Program;
|
||||
|
||||
where such changes and/or additions to the Program originate from and
|
||||
are distributed by that particular Contributor. A Contribution
|
||||
'originates' from a Contributor if it was added to the Program by such
|
||||
Contributor itself or anyone acting on such Contributor's behalf.
|
||||
Contributions do not include additions to the Program which: (i) are
|
||||
separate modules of software distributed in conjunction with the Program
|
||||
under their own license agreement, and (ii) are not derivative works of
|
||||
the Program.
|
||||
|
||||
"Contributor" means any person or entity that distributes the Program.
|
||||
|
||||
"Licensed Patents " mean patent claims licensable by a Contributor which
|
||||
are necessarily infringed by the use or sale of its Contribution alone
|
||||
or when combined with the Program.
|
||||
|
||||
"Program" means the Contributions distributed in accordance with this
|
||||
Agreement.
|
||||
|
||||
"Recipient" means anyone who receives the Program under this Agreement,
|
||||
including all Contributors.
|
||||
|
||||
*2. GRANT OF RIGHTS*
|
||||
|
||||
a) Subject to the terms of this Agreement, each Contributor hereby
|
||||
grants Recipient a non-exclusive, worldwide, royalty-free copyright
|
||||
license to reproduce, prepare derivative works of, publicly display,
|
||||
publicly perform, distribute and sublicense the Contribution of such
|
||||
Contributor, if any, and such derivative works, in source code and
|
||||
object code form.
|
||||
|
||||
b) Subject to the terms of this Agreement, each Contributor hereby
|
||||
grants Recipient a non-exclusive, worldwide, royalty-free patent license
|
||||
under Licensed Patents to make, use, sell, offer to sell, import and
|
||||
otherwise transfer the Contribution of such Contributor, if any, in
|
||||
source code and object code form. This patent license shall apply to the
|
||||
combination of the Contribution and the Program if, at the time the
|
||||
Contribution is added by the Contributor, such addition of the
|
||||
Contribution causes such combination to be covered by the Licensed
|
||||
Patents. The patent license shall not apply to any other combinations
|
||||
which include the Contribution. No hardware per se is licensed hereunder.
|
||||
|
||||
c) Recipient understands that although each Contributor grants the
|
||||
licenses to its Contributions set forth herein, no assurances are
|
||||
provided by any Contributor that the Program does not infringe the
|
||||
patent or other intellectual property rights of any other entity. Each
|
||||
Contributor disclaims any liability to Recipient for claims brought by
|
||||
any other entity based on infringement of intellectual property rights
|
||||
or otherwise. As a condition to exercising the rights and licenses
|
||||
granted hereunder, each Recipient hereby assumes sole responsibility to
|
||||
secure any other intellectual property rights needed, if any. For
|
||||
example, if a third party patent license is required to allow Recipient
|
||||
to distribute the Program, it is Recipient's responsibility to acquire
|
||||
that license before distributing the Program.
|
||||
|
||||
d) Each Contributor represents that to its knowledge it has sufficient
|
||||
copyright rights in its Contribution, if any, to grant the copyright
|
||||
license set forth in this Agreement.
|
||||
|
||||
*3. REQUIREMENTS*
|
||||
|
||||
A Contributor may choose to distribute the Program in object code form
|
||||
under its own license agreement, provided that:
|
||||
|
||||
a) it complies with the terms and conditions of this Agreement; and
|
||||
|
||||
b) its license agreement:
|
||||
|
||||
i) effectively disclaims on behalf of all Contributors all warranties
|
||||
and conditions, express and implied, including warranties or conditions
|
||||
of title and non-infringement, and implied warranties or conditions of
|
||||
merchantability and fitness for a particular purpose;
|
||||
|
||||
ii) effectively excludes on behalf of all Contributors all liability for
|
||||
damages, including direct, indirect, special, incidental and
|
||||
consequential damages, such as lost profits;
|
||||
|
||||
iii) states that any provisions which differ from this Agreement are
|
||||
offered by that Contributor alone and not by any other party; and
|
||||
|
||||
iv) states that source code for the Program is available from such
|
||||
Contributor, and informs licensees how to obtain it in a reasonable
|
||||
manner on or through a medium customarily used for software exchange.
|
||||
|
||||
When the Program is made available in source code form:
|
||||
|
||||
a) it must be made available under this Agreement; and
|
||||
|
||||
b) a copy of this Agreement must be included with each copy of the Program.
|
||||
|
||||
Contributors may not remove or alter any copyright notices contained
|
||||
within the Program.
|
||||
|
||||
Each Contributor must identify itself as the originator of its
|
||||
Contribution, if any, in a manner that reasonably allows subsequent
|
||||
Recipients to identify the originator of the Contribution.
|
||||
|
||||
*4. COMMERCIAL DISTRIBUTION*
|
||||
|
||||
Commercial distributors of software may accept certain responsibilities
|
||||
with respect to end users, business partners and the like. While this
|
||||
license is intended to facilitate the commercial use of the Program, the
|
||||
Contributor who includes the Program in a commercial product offering
|
||||
should do so in a manner which does not create potential liability for
|
||||
other Contributors. Therefore, if a Contributor includes the Program in
|
||||
a commercial product offering, such Contributor ("Commercial
|
||||
Contributor") hereby agrees to defend and indemnify every other
|
||||
Contributor ("Indemnified Contributor") against any losses, damages and
|
||||
costs (collectively "Losses") arising from claims, lawsuits and other
|
||||
legal actions brought by a third party against the Indemnified
|
||||
Contributor to the extent caused by the acts or omissions of such
|
||||
Commercial Contributor in connection with its distribution of the
|
||||
Program in a commercial product offering. The obligations in this
|
||||
section do not apply to any claims or Losses relating to any actual or
|
||||
alleged intellectual property infringement. In order to qualify, an
|
||||
Indemnified Contributor must: a) promptly notify the Commercial
|
||||
Contributor in writing of such claim, and b) allow the Commercial
|
||||
Contributor to control, and cooperate with the Commercial Contributor
|
||||
in, the defense and any related settlement negotiations. The Indemnified
|
||||
Contributor may participate in any such claim at its own expense.
|
||||
|
||||
For example, a Contributor might include the Program in a commercial
|
||||
product offering, Product X. That Contributor is then a Commercial
|
||||
Contributor. If that Commercial Contributor then makes performance
|
||||
claims, or offers warranties related to Product X, those performance
|
||||
claims and warranties are such Commercial Contributor's responsibility
|
||||
alone. Under this section, the Commercial Contributor would have to
|
||||
defend claims against the other Contributors related to those
|
||||
performance claims and warranties, and if a court requires any other
|
||||
Contributor to pay any damages as a result, the Commercial Contributor
|
||||
must pay those damages.
|
||||
|
||||
*5. NO WARRANTY*
|
||||
|
||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED
|
||||
ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES
|
||||
OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR
|
||||
A PARTICULAR PURPOSE. Each Recipient is solely responsible for
|
||||
determining the appropriateness of using and distributing the Program
|
||||
and assumes all risks associated with its exercise of rights under this
|
||||
Agreement , including but not limited to the risks and costs of program
|
||||
errors, compliance with applicable laws, damage to or loss of data,
|
||||
programs or equipment, and unavailability or interruption of operations.
|
||||
|
||||
*6. DISCLAIMER OF LIABILITY*
|
||||
|
||||
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
|
||||
ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
|
||||
WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
|
||||
DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
||||
HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
*7. GENERAL*
|
||||
|
||||
If any provision of this Agreement is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this Agreement, and without further action
|
||||
by the parties hereto, such provision shall be reformed to the minimum
|
||||
extent necessary to make such provision valid and enforceable.
|
||||
|
||||
If Recipient institutes patent litigation against any entity (including
|
||||
a cross-claim or counterclaim in a lawsuit) alleging that the Program
|
||||
itself (excluding combinations of the Program with other software or
|
||||
hardware) infringes such Recipient's patent(s), then such Recipient's
|
||||
rights granted under Section 2(b) shall terminate as of the date such
|
||||
litigation is filed.
|
||||
|
||||
All Recipient's rights under this Agreement shall terminate if it fails
|
||||
to comply with any of the material terms or conditions of this Agreement
|
||||
and does not cure such failure in a reasonable period of time after
|
||||
becoming aware of such noncompliance. If all Recipient's rights under
|
||||
this Agreement terminate, Recipient agrees to cease use and distribution
|
||||
of the Program as soon as reasonably practicable. However, Recipient's
|
||||
obligations under this Agreement and any licenses granted by Recipient
|
||||
relating to the Program shall continue and survive.
|
||||
|
||||
Everyone is permitted to copy and distribute copies of this Agreement,
|
||||
but in order to avoid inconsistency the Agreement is copyrighted and may
|
||||
only be modified in the following manner. The Agreement Steward reserves
|
||||
the right to publish new versions (including revisions) of this
|
||||
Agreement from time to time. No one other than the Agreement Steward has
|
||||
the right to modify this Agreement. The Eclipse Foundation is the
|
||||
initial Agreement Steward. The Eclipse Foundation may assign the
|
||||
responsibility to serve as the Agreement Steward to a suitable separate
|
||||
entity. Each new version of the Agreement will be given a distinguishing
|
||||
version number. The Program (including Contributions) may always be
|
||||
distributed subject to the version of the Agreement under which it was
|
||||
received. In addition, after a new version of the Agreement is
|
||||
published, Contributor may elect to distribute the Program (including
|
||||
its Contributions) under the new version. Except as expressly stated in
|
||||
Sections 2(a) and 2(b) above, Recipient receives no rights or licenses
|
||||
to the intellectual property of any Contributor under this Agreement,
|
||||
whether expressly, by implication, estoppel or otherwise. All rights in
|
||||
the Program not expressly granted under this Agreement are reserved.
|
||||
|
||||
This Agreement is governed by the laws of the State of New York and the
|
||||
intellectual property laws of the United States of America. No party to
|
||||
this Agreement will bring a legal action under this Agreement more than
|
||||
one year after the cause of action arose. Each party waives its rights
|
||||
to a jury trial in any resulting litigation.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
This project contains the tests for the Android Eclipse Plugins.
|
||||
|
||||
You can do two things:
|
||||
1- Run the full "eclipse plugin" suite
|
||||
2- Run independent JUnit tests (not as plugin)
|
||||
|
||||
------------------------------------------
|
||||
1- Running the full "eclipse plugin" suite
|
||||
------------------------------------------
|
||||
|
||||
Steps to run the test suite:
|
||||
|
||||
A- In Eclipse, import following projects from //device/tools/eclipse/plugins:
|
||||
- adt-tests
|
||||
- adt
|
||||
- common
|
||||
- editors
|
||||
|
||||
B- Create a new "JUnit Plug-in Test" run configuration via the "Run > Open Run Dialog..." menu
|
||||
Set the launch configuration's data as follows:
|
||||
i. "Test" tab:
|
||||
Select "Run a single test"
|
||||
Project: adt-tests
|
||||
Test class: com.android.ide.eclipse.tests.UnitTests
|
||||
Test runner: JUnit 3
|
||||
ii. "Arguments" tab:
|
||||
Set "VM Arguments" to
|
||||
"-Dtest_data=<adt>/plugins/com.android.ide.eclipse.tests/unittests/data/"
|
||||
replacing "<adt>" with absolute filesystem path to the android plugin source location
|
||||
|
||||
All other fields can be left with their default values
|
||||
|
||||
C. Run the newly created launch configuration
|
||||
|
||||
Running the tests will run a secondary instance of Eclipse.
|
||||
|
||||
Please note the following constraints to be aware of when writing tests to run within a plugin environment:
|
||||
|
||||
a. Access restrictions: cannot access package or protected members in a different
|
||||
plugin, even if they are in the same declared package
|
||||
b. Using classloader.getResource or getResourceAsStream to access test data will
|
||||
likely fail in the plugin environment. Instead, use AdtTestData to access test files
|
||||
in conjunction with the "test_data" environment variable mentioned above
|
||||
|
||||
|
||||
-------------------------------------------
|
||||
2- Run independent JUnit tests (not plugin)
|
||||
-------------------------------------------
|
||||
|
||||
A- In Eclipse, import following projects from //device/tools/eclipse/plugins:
|
||||
- adt-tests
|
||||
- adt
|
||||
- common
|
||||
- editors
|
||||
|
||||
B- Select the "unittests" source folder, right-click and select
|
||||
"Run As > JUnit Test" (i.e. not the plugin tests)
|
||||
|
||||
This creates a debug configuration of type "JUnit Test" running all tests
|
||||
in the source folder "unittests". The runtime must be JUnit 3.
|
||||
|
||||
Note: this method runs the tests within a regular JVM environment (ie not within
|
||||
an Eclipse instance). This method has the advantage of being quicker than running
|
||||
as a JUnit plugin test, and requires less potential set-up, but has the
|
||||
disadvantage of not properly replicating how the tests will be run in the
|
||||
continuous test environment. Tests that pass when run as "JUnit Tests" can
|
||||
fail when run as "JUnit Plugin Tests", due to the extra constraints imposed by
|
||||
running within an Eclipse plug-in noted in section 1.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
source.. = src/,\
|
||||
unittests/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
test.xml,\
|
||||
prefs.template,\
|
||||
unittest.xml,\
|
||||
kxml2-2.3.0.jar,\
|
||||
unittests/data/
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jar.example;
|
||||
|
||||
public class Class1 {
|
||||
|
||||
public static final int sStaticField = 1;
|
||||
|
||||
/** constructor */
|
||||
public Class1() {
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
public static class InnerStaticClass1 {
|
||||
|
||||
}
|
||||
|
||||
public class InnerClass2 {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jar.example;
|
||||
|
||||
public class Class2 extends Class1 {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#Wed Feb 20 16:56:40 PST 2008
|
||||
com.android.ide.eclipse.adt.sdk=sdk_home
|
||||
eclipse.preferences.version=1
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.adt.wizards.newproject;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Stub class for project creation page Returns canned responses for creating a
|
||||
* sample project
|
||||
*/
|
||||
public class StubSampleProjectCreationPage extends NewProjectCreationPage {
|
||||
|
||||
private String mSampleProjectName;
|
||||
private String mOsSdkLocation;
|
||||
|
||||
public StubSampleProjectCreationPage(String pageName,
|
||||
String sampleProjectName, String osSdkLocation) {
|
||||
super(pageName);
|
||||
this.mSampleProjectName = sampleProjectName;
|
||||
this.mOsSdkLocation = osSdkLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectName() {
|
||||
return mSampleProjectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return "com.android.samples";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivityName() {
|
||||
return mSampleProjectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationName() {
|
||||
return mSampleProjectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewProject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProjectLocation() {
|
||||
return mOsSdkLocation + File.separator + "samples" + File.separator + mSampleProjectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceFolder() {
|
||||
return "src";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.adt.wizards.newproject;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.wizard.IWizardContainer;
|
||||
import org.eclipse.jface.wizard.IWizardPage;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Stub class for project creation wizard Created so project creation logic can
|
||||
* be run without UI creation/manipulation Returns canned responses for creating
|
||||
* a sample project
|
||||
*/
|
||||
public class StubSampleProjectWizard extends NewProjectWizard {
|
||||
|
||||
private final String mSampleProjectName;
|
||||
private final String mOsSdkLocation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param sampleProjectName
|
||||
* @param osSdkLocation
|
||||
*/
|
||||
public StubSampleProjectWizard(String sampleProjectName, String osSdkLocation) {
|
||||
this.mSampleProjectName = sampleProjectName;
|
||||
this.mOsSdkLocation = osSdkLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent to return stub page
|
||||
*/
|
||||
@Override
|
||||
protected NewProjectCreationPage createMainPage() {
|
||||
return new StubSampleProjectCreationPage(MAIN_PAGE_NAME,
|
||||
mSampleProjectName, mOsSdkLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides parent to return dummy wizard container
|
||||
*/
|
||||
@Override
|
||||
public IWizardContainer getContainer() {
|
||||
return new IWizardContainer() {
|
||||
|
||||
public IWizardPage getCurrentPage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Shell getShell() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showPage(IWizardPage page) {
|
||||
// pass
|
||||
}
|
||||
|
||||
public void updateButtons() {
|
||||
// pass
|
||||
}
|
||||
|
||||
public void updateMessage() {
|
||||
// pass
|
||||
}
|
||||
|
||||
public void updateTitleBar() {
|
||||
// pass
|
||||
}
|
||||
|
||||
public void updateWindowTitle() {
|
||||
// pass
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes runnable on current thread
|
||||
*/
|
||||
public void run(boolean fork, boolean cancelable,
|
||||
IRunnableWithProgress runnable)
|
||||
throws InvocationTargetException, InterruptedException {
|
||||
runnable.run(new NullProgressMonitor());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Helper class for retrieving test data
|
||||
*
|
||||
* All tests which need to retrieve test data files should go through this class
|
||||
*
|
||||
*/
|
||||
public class AdtTestData {
|
||||
|
||||
/** singleton instance */
|
||||
private static AdtTestData sInstance = null;
|
||||
private static final Logger sLogger = Logger.getLogger(AdtTestData.class.getName());
|
||||
|
||||
/** the absolute file path to the /data directory in this test
|
||||
* environment.
|
||||
*/
|
||||
private String mOsRootDataPath;
|
||||
|
||||
|
||||
private AdtTestData() {
|
||||
// can set test_data env variable to override default behavior of
|
||||
// finding data using class loader
|
||||
// useful when running in plugin environment, where test data is inside
|
||||
// bundled jar, and must be extracted to temp filesystem location to be
|
||||
// accessed normally
|
||||
mOsRootDataPath = System.getProperty("test_data");
|
||||
if (mOsRootDataPath == null) {
|
||||
sLogger.info("Cannot find test_data directory, init to class loader");
|
||||
URL url = this.getClass().getClassLoader().getResource("data"); //$NON-NLS-1$
|
||||
mOsRootDataPath = url.getFile();
|
||||
}
|
||||
if (!mOsRootDataPath.endsWith(File.separator)) {
|
||||
sLogger.info("Fixing test_data env variable does not end with path separator");
|
||||
mOsRootDataPath = mOsRootDataPath.concat(File.separator);
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the singleton instance of AdtTestData */
|
||||
public static AdtTestData getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new AdtTestData();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/** Returns the absolute file path to a file located in this plugins
|
||||
* "data" directory
|
||||
* @param osRelativePath - string path to file contained in /data. Must
|
||||
* use path separators appropriate to host OS
|
||||
* @return String
|
||||
*/
|
||||
public String getTestFilePath(String osRelativePath) {
|
||||
return mOsRootDataPath + osRelativePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
|
||||
/**
|
||||
* Container TestSuite for all eclipse tests, both functional and unit
|
||||
*/
|
||||
public class AllTests extends TestSuite {
|
||||
|
||||
public AllTests() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a suite of test cases to be run.
|
||||
*/
|
||||
public static TestSuite suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(FuncTests.suite());
|
||||
suite.addTest(UnitTests.suite());
|
||||
return suite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class AndroidTestPlugin extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "com.android.ide.eclipse.adt.tests";
|
||||
|
||||
// The shared instance
|
||||
private static AndroidTestPlugin sPlugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public AndroidTestPlugin() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
sPlugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
sPlugin = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance
|
||||
*
|
||||
* @return the shared instance
|
||||
*/
|
||||
public static AndroidTestPlugin getDefault() {
|
||||
return sPlugin;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Class for collecting all test cases in an eclipse plugin
|
||||
*
|
||||
*/
|
||||
public class EclipseTestCollector {
|
||||
|
||||
private static final Logger sLogger = Logger.getLogger(EclipseTestCollector.class.getName());
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public EclipseTestCollector() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches through given plugin, adding all TestCase classes to given suite
|
||||
* @param suite - TestSuite to add to
|
||||
* @param plugin - Plugin to search for tests
|
||||
* @param expectedPackage - expected package for tests. Only test classes
|
||||
* that start with this package name will be added to suite
|
||||
*/
|
||||
public void addTestCases(TestSuite suite, Plugin plugin, String expectedPackage) {
|
||||
if (plugin != null) {
|
||||
Enumeration entries = plugin.getBundle().findEntries("/", "*.class", true);
|
||||
|
||||
while (entries.hasMoreElements()) {
|
||||
URL entry = (URL)entries.nextElement();
|
||||
String filePath = entry.getPath().replace(".class", "");
|
||||
try {
|
||||
Class testClass = getClass(filePath, expectedPackage);
|
||||
if (isTestClass(testClass)) {
|
||||
suite.addTestSuite(testClass);
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
// ignore, this is not the class we're looking for
|
||||
//sLogger.log(Level.INFO, "Could not load class " + filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given class shouk\ld be added to suite
|
||||
* @param testClass
|
||||
* @return
|
||||
*/
|
||||
protected boolean isTestClass(Class testClass) {
|
||||
return TestCase.class.isAssignableFrom(testClass) &&
|
||||
Modifier.isPublic(testClass.getModifiers()) &&
|
||||
hasPublicConstructor(testClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if given class has a public constructor
|
||||
* @param testClass
|
||||
* @return
|
||||
*/
|
||||
protected boolean hasPublicConstructor(Class testClass) {
|
||||
try {
|
||||
TestSuite.getTestConstructor(testClass);
|
||||
} catch(NoSuchMethodException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the class given by the plugin aka bundle file path
|
||||
* @param filePath - path of class in bundle
|
||||
* @param expectedPackage - expected package of class
|
||||
* @return
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
protected Class getClass(String filePath, String expectedPackage) throws ClassNotFoundException {
|
||||
String dotPath = filePath.replace('/', '.');
|
||||
// remove the output folders, by finding where package name starts
|
||||
int index = dotPath.indexOf(expectedPackage);
|
||||
if (index == -1) {
|
||||
throw new ClassNotFoundException();
|
||||
}
|
||||
String packagePath = dotPath.substring(index);
|
||||
return Class.forName(packagePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Generic superclass for Eclipse Android functional test cases, that provides
|
||||
* common facilities
|
||||
*/
|
||||
public class FuncTestCase extends TestCase {
|
||||
|
||||
private String mOsSdkLocation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @throws IllegalArgumentException if environment variable "sdk_home" is
|
||||
* not set
|
||||
*/
|
||||
protected FuncTestCase() {
|
||||
mOsSdkLocation = System.getProperty("sdk_home");
|
||||
if (mOsSdkLocation == null || mOsSdkLocation.length() < 1) {
|
||||
throw new IllegalArgumentException(
|
||||
"Environment variable sdk_home is not set");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute file system path of the Android SDK location to use
|
||||
* for this test
|
||||
*/
|
||||
protected String getOsSdkLocation() {
|
||||
return mOsSdkLocation;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
import com.android.ide.eclipse.tests.functests.sampleProjects.SampleProjectTest;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Container TestSuite for all eclipse tests to be run
|
||||
*/
|
||||
|
||||
public class FuncTests extends TestSuite {
|
||||
|
||||
static final String FUNC_TEST_PACKAGE = "com.android.ide.eclipse.tests.functests";
|
||||
|
||||
public FuncTests() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a suite of test cases to be run.
|
||||
* Needed for JUnit3 compliant command line test runner
|
||||
*/
|
||||
public static TestSuite suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
suite.addTestSuite(SampleProjectTest.class);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests;
|
||||
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Container TestSuite for all eclipse unit tests to be run
|
||||
*
|
||||
* Uses Eclipse OSGI to find and then run all junit.junit.framework.Tests in
|
||||
* this plugin, excluding tests in the FuncTests.FUNC_TEST_PACKAGE package
|
||||
*
|
||||
* Since it uses Eclipse OSGI, it must be run in a Eclipse plugin environment
|
||||
* i.e. from Eclipse workbench, this suite must be run using the
|
||||
* "JUnit Plug-in Test" launch configuration as opposed to as a "JUnit Test"
|
||||
*
|
||||
*/
|
||||
public class UnitTests {
|
||||
private static final String TEST_PACKAGE = "com.android.ide.eclipse";
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
|
||||
UnitTestCollector collector = new UnitTestCollector();
|
||||
collector.addTestCases(suite, AndroidTestPlugin.getDefault(), TEST_PACKAGE);
|
||||
return suite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized test collector which will skip adding functional tests
|
||||
*/
|
||||
private static class UnitTestCollector extends EclipseTestCollector {
|
||||
/**
|
||||
* Override parent class to exclude functional tests
|
||||
*/
|
||||
@Override
|
||||
protected boolean isTestClass(Class testClass) {
|
||||
return super.isTestClass(testClass) &&
|
||||
!testClass.getPackage().getName().startsWith(FuncTests.FUNC_TEST_PACKAGE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); you
|
||||
* may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.android.ide.eclipse.tests.functests.sampleProjects;
|
||||
|
||||
import com.android.ide.eclipse.adt.project.ProjectHelper;
|
||||
import com.android.ide.eclipse.adt.wizards.newproject.StubSampleProjectWizard;
|
||||
import com.android.ide.eclipse.tests.FuncTestCase;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IResourceChangeListener;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Test case that verifies all SDK sample projects can be imported, built in
|
||||
* Eclipse
|
||||
*
|
||||
* TODO: add support for deploying apps onto emulator and verifying successful
|
||||
* execution there
|
||||
*
|
||||
*/
|
||||
public class SampleProjectTest extends FuncTestCase {
|
||||
|
||||
private static final Logger sLogger = Logger.getLogger(SampleProjectTest.class.getName());
|
||||
|
||||
/**
|
||||
* Tests the sample project with the given name
|
||||
*
|
||||
* @param name - name of sample project to test
|
||||
*/
|
||||
protected void doTestSampleProject(String name) {
|
||||
try {
|
||||
|
||||
StubSampleProjectWizard newProjCreator = new StubSampleProjectWizard(
|
||||
name, getOsSdkLocation());
|
||||
newProjCreator.init(null, null);
|
||||
newProjCreator.performFinish();
|
||||
|
||||
IProject iproject = validateProjectExists(name);
|
||||
|
||||
validateNoProblems(iproject);
|
||||
|
||||
}
|
||||
catch (CoreException e) {
|
||||
fail("Unexpected exception when creating sample project: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void testApiDemos() {
|
||||
doTestSampleProject("ApiDemos");
|
||||
}
|
||||
|
||||
public void testHelloActivity() {
|
||||
doTestSampleProject("HelloActivity");
|
||||
}
|
||||
|
||||
public void testLunarLander() {
|
||||
doTestSampleProject("LunarLander");
|
||||
}
|
||||
|
||||
public void testNotePad() {
|
||||
doTestSampleProject("NotePad");
|
||||
}
|
||||
|
||||
public void testSkeletonApp() {
|
||||
doTestSampleProject("SkeletonApp");
|
||||
}
|
||||
|
||||
public void testSnake() {
|
||||
doTestSampleProject("Snake");
|
||||
}
|
||||
|
||||
private IProject validateProjectExists(String name) {
|
||||
IProject iproject = getIProject(name);
|
||||
assertTrue(iproject.exists());
|
||||
assertTrue(iproject.isOpen());
|
||||
return iproject;
|
||||
}
|
||||
|
||||
private IProject getIProject(String name) {
|
||||
IProject iproject = ResourcesPlugin.getWorkspace().getRoot()
|
||||
.getProject(name);
|
||||
return iproject;
|
||||
}
|
||||
|
||||
private void validateNoProblems(IProject iproject) throws CoreException {
|
||||
waitForBuild(iproject);
|
||||
assertFalse(ProjectHelper.hasError(iproject, true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Waits for build to complete.
|
||||
*
|
||||
* @param iproject
|
||||
*/
|
||||
private void waitForBuild(final IProject iproject) {
|
||||
|
||||
final BuiltProjectDeltaVisitor deltaVisitor = new BuiltProjectDeltaVisitor(iproject);
|
||||
IResourceChangeListener newBuildListener = new IResourceChangeListener() {
|
||||
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
try {
|
||||
event.getDelta().accept(deltaVisitor);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
iproject.getWorkspace().addResourceChangeListener(newBuildListener,
|
||||
IResourceChangeEvent.POST_BUILD);
|
||||
|
||||
// poll build listener to determine when build is done
|
||||
// loop max of 1200 times * 50 ms = 60 seconds
|
||||
final int maxWait = 1200;
|
||||
for (int i=0; i < maxWait; i++) {
|
||||
if (deltaVisitor.isProjectBuilt()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
if (Display.getCurrent() != null) {
|
||||
Display.getCurrent().readAndDispatch();
|
||||
}
|
||||
}
|
||||
|
||||
sLogger.log(Level.SEVERE, "expected build event never happened?");
|
||||
fail("expected build event never happened for " + iproject.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans a given IResourceDelta looking for a "build event" change for given IProject
|
||||
*
|
||||
*/
|
||||
private class BuiltProjectDeltaVisitor implements IResourceDeltaVisitor {
|
||||
|
||||
private IProject mIProject;
|
||||
private boolean mIsBuilt;
|
||||
|
||||
public BuiltProjectDeltaVisitor(IProject iproject) {
|
||||
mIProject = iproject;
|
||||
mIsBuilt = false;
|
||||
}
|
||||
|
||||
public boolean visit(IResourceDelta delta) {
|
||||
if (mIProject.equals(delta.getResource())) {
|
||||
setBuilt(true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private synchronized void setBuilt(boolean b) {
|
||||
mIsBuilt = b;
|
||||
}
|
||||
|
||||
public synchronized boolean isProjectBuilt() {
|
||||
return mIsBuilt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
76
tools/eclipse/plugins/com.android.ide.eclipse.tests/test.xml
Normal file
76
tools/eclipse/plugins/com.android.ide.eclipse.tests/test.xml
Normal file
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- test launcher file for Android Eclipse functional tests -->
|
||||
<project name="testsuite" default="run" basedir=".">
|
||||
<!--The following properties should be passed into this script, set to some default value for now -->
|
||||
<property name="eclipse.home" value="/opt/eclipse" />
|
||||
<property name="sdk_home" value="/tmp/sdk" />
|
||||
<property name="eclipse_test" value="${eclipse.home}/plugins/org.eclipse.test_3.2.0" />
|
||||
|
||||
<!-- eclipse scripts use an annoying mixture of eclipse-home and eclipse.home -->
|
||||
<!-- lets define both...-->
|
||||
<property name="eclipse-home" value="${eclipse.home}" />
|
||||
<property name="test-folder" value="${eclipse.home}/test_folder" />
|
||||
|
||||
<!-- sets the properties eclipse.home, and library-file -->
|
||||
<property name="plugin-name" value="com.android.ide.eclipse.tests" />
|
||||
<property name="library-file" value="${eclipse_test}/library.xml" />
|
||||
|
||||
<!-- location of adt preference file (within workspace) -->
|
||||
<property name="prefs_path" value="${test-folder}/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.android.ide.eclipse.adt.prefs" />
|
||||
<!-- location of pref template file relative to this file -->
|
||||
|
||||
<property name="prefs_template" value="prefs.template" />
|
||||
|
||||
<!-- This target holds all initialization code that needs to be done for -->
|
||||
<!-- all tests that are to be run. -->
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<echo message="eclipse.home: ${eclipse.home}" />
|
||||
<echo message="libfile: ${library-file}" />
|
||||
|
||||
<!-- delete test eclipse workspace -->
|
||||
<delete dir="${test-folder}" quiet="true" />
|
||||
|
||||
<!-- delete test results dir -->
|
||||
<delete dir="${eclipse.home}/results" quiet="true" />
|
||||
|
||||
<!-- Copy a preference file into the test workspace. -->
|
||||
<!-- This is done to ensure Android SDK preference is set on startup -->
|
||||
<copy file="${prefs_template}" tofile="${prefs_path}" />
|
||||
<!-- replace sdk path placeholder token with actual sdk path -->
|
||||
<replace file="${prefs_path}" token="sdk_home" value="${sdk_home}" />
|
||||
|
||||
<!-- if this is on windows, escape the drive and file separators -->
|
||||
<replace file="${prefs_path}" token="\" value="\\" />
|
||||
<replace file="${prefs_path}" token=":" value="\:" />
|
||||
</target>
|
||||
|
||||
<!-- This target defines the tests that need to be run. -->
|
||||
<target name="suite">
|
||||
<!-- launch as ui-test ie as a test which needs Eclipse workbench -->
|
||||
<ant target="ui-test" antfile="${library-file}" dir="${eclipse.home}">
|
||||
<property name="data-dir" value="${test-folder}" />
|
||||
<property name="plugin-name" value="${plugin-name}" />
|
||||
<property name="classname" value="com.android.ide.eclipse.tests.FuncTests" />
|
||||
<!-- pass extra vm arg to set sdk_home env variable -->
|
||||
<property name="extraVMargs" value="-Dsdk_home=${sdk_home}" />
|
||||
</ant>
|
||||
</target>
|
||||
|
||||
<!-- This target holds code to cleanup the testing environment after -->
|
||||
<!-- after all of the tests have been run. You can use this target to -->
|
||||
<!-- delete temporary files that have been created. -->
|
||||
<target name="cleanup">
|
||||
</target>
|
||||
|
||||
<!-- This target runs the test suite. Any actions that need to happen -->
|
||||
<!-- after all the tests have been run should go here. -->
|
||||
<target name="run" depends="init,suite,cleanup">
|
||||
<ant target="collect" antfile="${library-file}" dir="${eclipse.home}/results">
|
||||
<property name="includes" value="com*.xml" />
|
||||
<property name="output-file" value="${plugin-name}.xml" />
|
||||
</ant>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- test launcher file for Android Eclipse unit tests -->
|
||||
<project name="testsuite" default="run" basedir=".">
|
||||
<!--The following properties should be passed into this script, set to some default value for now -->
|
||||
<property name="eclipse.home" value="/opt/eclipse" />
|
||||
<property name="eclipse_test" value="${eclipse.home}/plugins/org.eclipse.test_3.2.0" />
|
||||
|
||||
<!-- eclipse scripts use an annoying mixture of eclipse-home and eclipse.home -->
|
||||
<!-- lets define both...-->
|
||||
<property name="eclipse-home" value="${eclipse.home}" />
|
||||
<property name="test-folder" value="${eclipse.home}/unittest_ws" />
|
||||
|
||||
<!-- sets the properties eclipse.home, and library-file -->
|
||||
<property name="plugin-name" value="com.android.ide.eclipse.tests" />
|
||||
<property name="library-file" value="${eclipse_test}/library.xml" />
|
||||
|
||||
<!-- This target holds all initialization code that needs to be done for -->
|
||||
<!-- all tests that are to be run. -->
|
||||
<target name="init">
|
||||
<ant antfile="test.xml" target="init">
|
||||
<property name="test-folder" value="${test-folder}" />
|
||||
</ant>
|
||||
</target>
|
||||
|
||||
<!-- This target defines the tests that need to be run. -->
|
||||
<target name="suite">
|
||||
<!-- need to launch as ui-test since all ADT plugins depend on ui-->
|
||||
<!-- otherwise other plugins will not load -->
|
||||
<ant target="ui-test" antfile="${library-file}" dir="${eclipse.home}">
|
||||
<property name="data-dir" value="${test-folder}" />
|
||||
<property name="plugin-name" value="${plugin-name}" />
|
||||
<property name="classname" value="com.android.ide.eclipse.tests.UnitTests" />
|
||||
<!-- pass extra vm arg to set test_data env variable -->
|
||||
<property name="extraVMargs" value="-Dtest_data=${test_data}" />
|
||||
</ant>
|
||||
</target>
|
||||
|
||||
<!-- This target holds code to cleanup the testing environment after -->
|
||||
<!-- after all of the tests have been run. You can use this target to -->
|
||||
<!-- delete temporary files that have been created. -->
|
||||
<target name="cleanup">
|
||||
</target>
|
||||
|
||||
<!-- This target runs the test suite. Any actions that need to happen -->
|
||||
<!-- after all the tests have been run should go here. -->
|
||||
<target name="run" depends="init,suite,cleanup">
|
||||
<ant target="collect" antfile="${library-file}" dir="${eclipse.home}/results">
|
||||
<property name="includes" value="com*.xml" />
|
||||
<property name="output-file" value="${plugin-name}.xml" />
|
||||
</ant>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.build;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class BaseBuilderTest extends TestCase {
|
||||
|
||||
public void testParseAaptOutput() {
|
||||
Pattern p = Pattern.compile( "^(.+):(\\d+):\\s(.+)$"); //$NON-NLS-1$
|
||||
String s = "C:\\java\\workspace-android\\AndroidApp\\res\\values\\strings.xml:11: WARNING: empty 'some warning text";
|
||||
|
||||
Matcher m = p.matcher(s);
|
||||
assertEquals(true, m.matches());
|
||||
assertEquals("C:\\java\\workspace-android\\AndroidApp\\res\\values\\strings.xml", m.group(1));
|
||||
assertEquals("11", m.group(2));
|
||||
assertEquals("WARNING: empty 'some warning text", m.group(3));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.project;
|
||||
|
||||
import com.android.ide.eclipse.mock.ClasspathEntryMock;
|
||||
import com.android.ide.eclipse.mock.JavaProjectMock;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ProjectHelperTest extends TestCase {
|
||||
|
||||
/** The old container id */
|
||||
private final static String OLD_CONTAINER_ID =
|
||||
"com.android.ide.eclipse.adt.project.AndroidClasspathContainerInitializer"; //$NON-NLS-1$
|
||||
|
||||
/** The container id for the android framework jar file */
|
||||
private final static String CONTAINER_ID =
|
||||
"com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"; //$NON-NLS-1$
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
// pass for now
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
// pass for now
|
||||
}
|
||||
|
||||
public final void testFixProjectClasspathEntriesFromOldContainer() throws JavaModelException {
|
||||
// create a project with a path to an android .zip
|
||||
JavaProjectMock javaProject = new JavaProjectMock(
|
||||
new IClasspathEntry[] {
|
||||
new ClasspathEntryMock(new Path("Project/src"), //$NON-NLS-1$
|
||||
IClasspathEntry.CPE_SOURCE),
|
||||
new ClasspathEntryMock(new Path(OLD_CONTAINER_ID),
|
||||
IClasspathEntry.CPE_CONTAINER),
|
||||
},
|
||||
new Path("Project/bin"));
|
||||
|
||||
ProjectHelper.fixProjectClasspathEntries(javaProject);
|
||||
|
||||
IClasspathEntry[] fixedEntries = javaProject.getRawClasspath();
|
||||
assertEquals(3, fixedEntries.length);
|
||||
assertEquals("Project/src", fixedEntries[0].getPath().toString());
|
||||
assertEquals(OLD_CONTAINER_ID, fixedEntries[1].getPath().toString());
|
||||
assertEquals(CONTAINER_ID, fixedEntries[2].getPath().toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.sdk;
|
||||
|
||||
import com.android.ide.eclipse.adt.sdk.IAndroidClassLoader.IClassDescriptor;
|
||||
import com.android.ide.eclipse.tests.AdtTestData;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit Test for {@link AndroidJarLoader}.
|
||||
*
|
||||
* Uses the classes jar.example.Class1/Class2 stored in tests/data/jar_example.jar.
|
||||
*/
|
||||
public class AndroidJarLoaderTest extends TestCase {
|
||||
|
||||
private AndroidJarLoader mFrameworkClassLoader;
|
||||
|
||||
/** Creates an instance of {@link AndroidJarLoader} on our test data JAR */
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
String jarfilePath = AdtTestData.getInstance().getTestFilePath("jar_example.jar"); //$NON-NLS-1$
|
||||
mFrameworkClassLoader = new AndroidJarLoader(jarfilePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
mFrameworkClassLoader = null;
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/** Preloads classes. They should load just fine. */
|
||||
public final void testPreLoadClasses() throws Exception {
|
||||
mFrameworkClassLoader.preLoadClasses("jar.example.", null, null); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertEquals(0, map.size());
|
||||
HashMap<String,byte[]> data = getPrivateEntryCache();
|
||||
assertTrue(data.containsKey("jar.example.Class1")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class1$InnerStaticClass1")); //$NON-NLS-1$
|
||||
assertTrue(data.containsKey("jar.example.Class1$InnerClass2")); //$NON-NLS-1$
|
||||
assertEquals(4, data.size());
|
||||
}
|
||||
|
||||
/** Preloads a class not in the JAR. Preloading does nothing in this case. */
|
||||
public final void testPreLoadClasses_classNotFound() throws Exception {
|
||||
mFrameworkClassLoader.preLoadClasses("not.a.package.", null, null); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertEquals(0, map.size());
|
||||
HashMap<String,byte[]> data = getPrivateEntryCache();
|
||||
assertEquals(0, data.size());
|
||||
}
|
||||
|
||||
/** Finds a class we just preloaded. It should work. */
|
||||
public final void testFindClass_classFound() throws Exception {
|
||||
Class<?> c = _findClass(mFrameworkClassLoader, "jar.example.Class2"); //$NON-NLS-1$
|
||||
assertEquals("jar.example.Class2", c.getName()); //$NON-NLS-1$
|
||||
HashMap<String, Class<?>> map = getPrivateClassCache();
|
||||
assertTrue(map.containsKey("jar.example.Class1")); //$NON-NLS-1$
|
||||
assertTrue(map.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertEquals(2, map.size());
|
||||
}
|
||||
|
||||
/** call the protected method findClass */
|
||||
private Class<?> _findClass(AndroidJarLoader jarLoader, String name) throws Exception {
|
||||
Method findClassMethod = AndroidJarLoader.class.getDeclaredMethod(
|
||||
"findClass", String.class); //$NON-NLS-1$
|
||||
findClassMethod.setAccessible(true);
|
||||
try {
|
||||
return (Class<?>)findClassMethod.invoke(jarLoader, name);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
throw (Exception)e.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
/** Trying to find a class that we fail to preload should throw a CNFE. */
|
||||
public final void testFindClass_classNotFound() throws Exception {
|
||||
try {
|
||||
// Will throw ClassNotFoundException
|
||||
_findClass(mFrameworkClassLoader, "not.a.valid.ClassName"); //$NON-NLS-1$
|
||||
} catch (ClassNotFoundException e) {
|
||||
// check the message in the CNFE
|
||||
assertEquals("not.a.valid.ClassName", e.getMessage()); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
// Exception not thrown - this is a failure
|
||||
fail("Expected ClassNotFoundException not thrown");
|
||||
}
|
||||
|
||||
public final void testFindClassesDerivingFrom() throws Exception {
|
||||
HashMap<String, ArrayList<IClassDescriptor>> found =
|
||||
mFrameworkClassLoader.findClassesDerivingFrom("jar.example.", new String[] { //$NON-NLS-1$
|
||||
"jar.example.Class1", //$NON-NLS-1$
|
||||
"jar.example.Class2" }); //$NON-NLS-1$
|
||||
|
||||
assertTrue(found.containsKey("jar.example.Class1")); //$NON-NLS-1$
|
||||
assertTrue(found.containsKey("jar.example.Class2")); //$NON-NLS-1$
|
||||
assertEquals(2, found.size());
|
||||
// Only Class2 derives from Class1..
|
||||
// Class1 and Class1$InnerStaticClass1 derive from Object and are thus ignored.
|
||||
// Class1$InnerClass2 should never be seen either.
|
||||
assertEquals("jar.example.Class2", //$NON-NLS-1$
|
||||
found.get("jar.example.Class1").get(0).getCanonicalName()); //$NON-NLS-1$
|
||||
assertEquals(1, found.get("jar.example.Class1").size()); //$NON-NLS-1$
|
||||
assertEquals(0, found.get("jar.example.Class2").size()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// --- Utilities ---
|
||||
|
||||
/**
|
||||
* Retrieves the private mFrameworkClassLoader.mClassCache field using reflection.
|
||||
*
|
||||
* @throws NoSuchFieldException
|
||||
* @throws SecurityException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<String, Class<?> > getPrivateClassCache()
|
||||
throws SecurityException, NoSuchFieldException,
|
||||
IllegalArgumentException, IllegalAccessException {
|
||||
Field field = AndroidJarLoader.class.getDeclaredField("mClassCache"); //$NON-NLS-1$
|
||||
field.setAccessible(true);
|
||||
return (HashMap<String, Class<?>>) field.get(mFrameworkClassLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the private mFrameworkClassLoader.mEntryCache field using reflection.
|
||||
*
|
||||
* @throws NoSuchFieldException
|
||||
* @throws SecurityException
|
||||
* @throws IllegalAccessException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private HashMap<String,byte[]> getPrivateEntryCache()
|
||||
throws SecurityException, NoSuchFieldException,
|
||||
IllegalArgumentException, IllegalAccessException {
|
||||
Field field = AndroidJarLoader.class.getDeclaredField("mEntryCache"); //$NON-NLS-1$
|
||||
field.setAccessible(true);
|
||||
return (HashMap<String, byte[]>) field.get(mFrameworkClassLoader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.sdk;
|
||||
|
||||
import com.android.ide.eclipse.adt.sdk.AndroidJarLoader.ClassWrapper;
|
||||
import com.android.ide.eclipse.adt.sdk.IAndroidClassLoader.IClassDescriptor;
|
||||
import com.android.ide.eclipse.common.resources.AttrsXmlParser;
|
||||
import com.android.ide.eclipse.common.resources.ViewClassInfo;
|
||||
import com.android.ide.eclipse.common.resources.ViewClassInfo.LayoutParamsInfo;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test the inner private methods of PlatformDataParser.
|
||||
*
|
||||
* Convention: method names that start with an underscore are actually local wrappers
|
||||
* that call private methods from {@link AndroidTargetParser} using reflection.
|
||||
* This is inspired by the Python coding rule which mandates underscores prefixes for
|
||||
* "private" methods.
|
||||
*/
|
||||
public class LayoutParamsParserTest extends TestCase {
|
||||
|
||||
private static class MockFrameworkClassLoader extends AndroidJarLoader {
|
||||
MockFrameworkClassLoader() {
|
||||
super(null /* osFrameworkLocation */);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, ArrayList<IClassDescriptor>> findClassesDerivingFrom(
|
||||
String rootPackage, String[] superClasses) throws ClassFormatError {
|
||||
return new HashMap<String, ArrayList<IClassDescriptor>>();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MockAttrsXmlPath {
|
||||
public String getPath() {
|
||||
ClassLoader cl = this.getClass().getClassLoader();
|
||||
URL res = cl.getResource("data/mock_attrs.xml"); //$NON-NLS-1$
|
||||
return res.getFile();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MockLayoutParamsParser extends LayoutParamsParser {
|
||||
public MockLayoutParamsParser() {
|
||||
super(new MockFrameworkClassLoader(),
|
||||
new AttrsXmlParser(new MockAttrsXmlPath().getPath()).preload());
|
||||
|
||||
mTopViewClass = new ClassWrapper(mock_android.view.View.class);
|
||||
mTopGroupClass = new ClassWrapper(mock_android.view.ViewGroup.class);
|
||||
mTopLayoutParamsClass = new ClassWrapper(mock_android.view.ViewGroup.LayoutParams.class);
|
||||
|
||||
mViewList = new ArrayList<IClassDescriptor>();
|
||||
mGroupList = new ArrayList<IClassDescriptor>();
|
||||
mViewMap = new TreeMap<String, ExtViewClassInfo>();
|
||||
mGroupMap = new TreeMap<String, ExtViewClassInfo>();
|
||||
mLayoutParamsMap = new HashMap<String, LayoutParamsInfo>();
|
||||
}
|
||||
}
|
||||
|
||||
private MockLayoutParamsParser mParser;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
mParser = new MockLayoutParamsParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public final void testFindLayoutParams() throws Exception {
|
||||
assertEquals(mock_android.view.ViewGroup.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.view.ViewGroup.class)).wrappedClass());
|
||||
|
||||
assertEquals(mock_android.widget.LinearLayout.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.widget.LinearLayout.class)).wrappedClass());
|
||||
|
||||
assertEquals(mock_android.widget.TableLayout.LayoutParams.class,
|
||||
((ClassWrapper)_findLayoutParams(mock_android.widget.TableLayout.class)).wrappedClass());
|
||||
}
|
||||
|
||||
public final void testGetLayoutParamsInfo() throws Exception {
|
||||
LayoutParamsInfo info1 = _getLayoutParamsInfo(
|
||||
mock_android.view.ViewGroup.LayoutParams.class);
|
||||
assertNotNull(info1);
|
||||
// ViewGroup.LayoutData has Object for superClass, which we don't map
|
||||
assertNull(info1.getSuperClass());
|
||||
|
||||
LayoutParamsInfo info2 = _getLayoutParamsInfo(
|
||||
mock_android.widget.LinearLayout.LayoutParams.class);
|
||||
assertNotNull(info2);
|
||||
// LinearLayout.LayoutData links to ViewGroup.LayoutParams
|
||||
assertSame(info1, info2.getSuperClass());
|
||||
|
||||
LayoutParamsInfo info3 = _getLayoutParamsInfo(
|
||||
mock_android.widget.TableLayout.LayoutParams.class);
|
||||
assertNotNull(info3);
|
||||
// TableLayout.LayoutData does not link to ViewGroup.LayoutParams nor
|
||||
// LinearLayout.LayoutParams
|
||||
assertNotSame(info1, info3.getSuperClass());
|
||||
assertNotSame(info2, info3.getSuperClass());
|
||||
// TableLayout.LayoutParams => ViewGroup.MarginLayoutParams => ViewGroup.LayoutParams
|
||||
assertSame(info1, info3.getSuperClass().getSuperClass());
|
||||
}
|
||||
|
||||
public final void testGetLayoutClasses() throws Exception {
|
||||
// _getLayoutClasses();
|
||||
}
|
||||
|
||||
//---- access to private methods
|
||||
|
||||
/** Calls the private constructor of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private AndroidTargetParser _Constructor(String osJarPath) throws Exception {
|
||||
Constructor<AndroidTargetParser> constructor =
|
||||
AndroidTargetParser.class.getDeclaredConstructor(String.class);
|
||||
constructor.setAccessible(true);
|
||||
return constructor.newInstance(osJarPath);
|
||||
}
|
||||
|
||||
/** calls the private getLayoutClasses() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private void _getLayoutClasses() throws Exception {
|
||||
Method method = AndroidTargetParser.class.getDeclaredMethod("getLayoutClasses"); //$NON-NLS-1$
|
||||
method.setAccessible(true);
|
||||
method.invoke(mParser);
|
||||
}
|
||||
|
||||
/** calls the private addGroup() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private ViewClassInfo _addGroup(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addGroup", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
method.setAccessible(true);
|
||||
return (ViewClassInfo) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
/** calls the private addLayoutParams() of the parser */
|
||||
@SuppressWarnings("unused")
|
||||
private LayoutParamsInfo _addLayoutParams(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("addLayoutParams", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
method.setAccessible(true);
|
||||
return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
/** calls the private getLayoutParamsInfo() of the parser */
|
||||
private LayoutParamsInfo _getLayoutParamsInfo(Class<?> layoutParamsClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("getLayoutParamsInfo", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
method.setAccessible(true);
|
||||
return (LayoutParamsInfo) method.invoke(mParser, new ClassWrapper(layoutParamsClass));
|
||||
}
|
||||
|
||||
/** calls the private findLayoutParams() of the parser */
|
||||
private IClassDescriptor _findLayoutParams(Class<?> groupClass) throws Exception {
|
||||
Method method = LayoutParamsParser.class.getDeclaredMethod("findLayoutParams", //$NON-NLS-1$
|
||||
IClassDescriptor.class);
|
||||
method.setAccessible(true);
|
||||
return (IClassDescriptor) method.invoke(mParser, new ClassWrapper(groupClass));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.common.project;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AndroidManifestHelperTest extends TestCase {
|
||||
private File mFile;
|
||||
private AndroidManifestHelper mManifest;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mFile = File.createTempFile("androidManifest", "xml"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
assertNotNull(mFile);
|
||||
|
||||
FileWriter fw = new FileWriter(mFile);
|
||||
fw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); //$NON-NLS-1$
|
||||
fw.write("<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"); //$NON-NLS-1$
|
||||
fw.write(" package=\"com.android.testapp\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <application android:icon=\"@drawable/icon\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".MainActivity\" android:label=\"@string/app_name\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"android.intent.action.MAIN\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.LAUNCHER\" />\"\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.DEFAULT\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".OptionsActivity\" android:label=\"@string/options\"\n"); //$NON-NLS-1$
|
||||
fw.write(" android:theme=\"@style/Theme.Floating\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"com.android.mandelbrot.action.EDIT_OPTIONS\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" <category android:name=\"android.intent.category.PREFERENCE_CATEGORY\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" <activity android:name=\".InfoActivity\" android:label=\"@string/options\"\n"); //$NON-NLS-1$
|
||||
fw.write(" android:theme=\"@style/Theme.Floating\">\n"); //$NON-NLS-1$
|
||||
fw.write(" <intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" <action android:name=\"com.android.mandelbrot.action.DISPLAY_INFO\" />\n"); //$NON-NLS-1$
|
||||
fw.write(" </intent-filter>\n"); //$NON-NLS-1$
|
||||
fw.write(" </activity>\n"); //$NON-NLS-1$
|
||||
fw.write(" </application>\n"); //$NON-NLS-1$
|
||||
fw.write("</manifest>\n"); //$NON-NLS-1$
|
||||
fw.flush();
|
||||
fw.close();
|
||||
|
||||
mManifest = new AndroidManifestHelper(mFile.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
assertTrue(mFile.delete());
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testExists() {
|
||||
assertTrue(mManifest.exists());
|
||||
}
|
||||
|
||||
public void testNotExists() throws IOException {
|
||||
File f = File.createTempFile("androidManifest2", "xml"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
assertTrue(f.delete());
|
||||
AndroidManifestHelper manifest = new AndroidManifestHelper(f.getAbsolutePath());
|
||||
assertFalse(manifest.exists());
|
||||
}
|
||||
|
||||
public void testGetPackageName() {
|
||||
assertEquals("com.android.testapp", mManifest.getPackageName());
|
||||
}
|
||||
|
||||
public void testGetActivityName() {
|
||||
assertEquals("", mManifest.getActivityName(0)); //$NON-NLS-1$
|
||||
assertEquals(".MainActivity", mManifest.getActivityName(1)); //$NON-NLS-1$
|
||||
assertEquals(".OptionsActivity", mManifest.getActivityName(2)); //$NON-NLS-1$
|
||||
assertEquals(".InfoActivity", mManifest.getActivityName(3)); //$NON-NLS-1$
|
||||
assertEquals("", mManifest.getActivityName(4)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.common.resources;
|
||||
|
||||
|
||||
import com.android.ide.eclipse.common.resources.DeclareStyleableInfo.AttributeInfo;
|
||||
import com.android.ide.eclipse.common.resources.DeclareStyleableInfo.AttributeInfo.Format;
|
||||
import com.android.ide.eclipse.tests.AdtTestData;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class AttrsXmlParserTest extends TestCase {
|
||||
|
||||
private AttrsXmlParser mParser;
|
||||
private String mFilePath;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
mFilePath = AdtTestData.getInstance().getTestFilePath("mock_attrs.xml"); //$NON-NLS-1$
|
||||
mParser = new AttrsXmlParser(mFilePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public final void testGetDocument() throws Exception {
|
||||
assertNotNull(_getDocument());
|
||||
}
|
||||
|
||||
public void testGetOsAttrsXmlPath() throws Exception {
|
||||
assertEquals(mFilePath, mParser.getOsAttrsXmlPath());
|
||||
}
|
||||
|
||||
public final void testPreload() throws Exception {
|
||||
assertSame(mParser, mParser.preload());
|
||||
}
|
||||
|
||||
|
||||
public final void testLoadViewAttributes() throws Exception {
|
||||
mParser.preload();
|
||||
ViewClassInfo info = new ViewClassInfo(
|
||||
false /* isLayout */,
|
||||
"mock_android.something.Theme", //$NON-NLS-1$
|
||||
"Theme"); //$NON-NLS-1$
|
||||
mParser.loadViewAttributes(info);
|
||||
|
||||
assertEquals("These are the standard attributes that make up a complete theme.", //$NON-NLS-1$
|
||||
info.getJavaDoc());
|
||||
AttributeInfo[] attrs = info.getAttributes();
|
||||
assertEquals(1, attrs.length);
|
||||
assertEquals("scrollbarSize", info.getAttributes()[0].getName());
|
||||
assertEquals(1, info.getAttributes()[0].getFormats().length);
|
||||
assertEquals(Format.DIMENSION, info.getAttributes()[0].getFormats()[0]);
|
||||
}
|
||||
|
||||
public final void testEnumFlagValues() throws Exception {
|
||||
/* The XML being read contains:
|
||||
<!-- Standard orientation constant. -->
|
||||
<attr name="orientation">
|
||||
<!-- Defines an horizontal widget. -->
|
||||
<enum name="horizontal" value="0" />
|
||||
<!-- Defines a vertical widget. -->
|
||||
<enum name="vertical" value="1" />
|
||||
</attr>
|
||||
*/
|
||||
|
||||
mParser.preload();
|
||||
Map<String, Map<String, Integer>> attrMap = mParser.getEnumFlagValues();
|
||||
assertTrue(attrMap.containsKey("orientation"));
|
||||
|
||||
Map<String, Integer> valueMap = attrMap.get("orientation");
|
||||
assertTrue(valueMap.containsKey("horizontal"));
|
||||
assertTrue(valueMap.containsKey("vertical"));
|
||||
assertEquals(Integer.valueOf(0), valueMap.get("horizontal"));
|
||||
assertEquals(Integer.valueOf(1), valueMap.get("vertical"));
|
||||
}
|
||||
|
||||
public final void testDeprecated() throws Exception {
|
||||
mParser.preload();
|
||||
|
||||
DeclareStyleableInfo dep = mParser.getDeclareStyleableList().get("DeprecatedTest");
|
||||
assertNotNull(dep);
|
||||
|
||||
AttributeInfo[] attrs = dep.getAttributes();
|
||||
assertEquals(4, attrs.length);
|
||||
|
||||
assertEquals("deprecated-inline", attrs[0].getName());
|
||||
assertEquals("In-line deprecated.", attrs[0].getDeprecatedDoc());
|
||||
assertEquals("Deprecated comments using delimiters.", attrs[0].getJavaDoc());
|
||||
|
||||
assertEquals("deprecated-multiline", attrs[1].getName());
|
||||
assertEquals("Multi-line version of deprecated that works till the next tag.",
|
||||
attrs[1].getDeprecatedDoc());
|
||||
assertEquals("Deprecated comments on their own line.", attrs[1].getJavaDoc());
|
||||
|
||||
assertEquals("deprecated-not", attrs[2].getName());
|
||||
assertEquals(null, attrs[2].getDeprecatedDoc());
|
||||
assertEquals("This attribute is not deprecated.", attrs[2].getJavaDoc());
|
||||
|
||||
assertEquals("deprecated-no-javadoc", attrs[3].getName());
|
||||
assertEquals("There is no other javadoc here.", attrs[3].getDeprecatedDoc());
|
||||
assertEquals("", attrs[3].getJavaDoc());
|
||||
}
|
||||
|
||||
//---- access to private methods
|
||||
|
||||
private Document _getDocument() throws Exception {
|
||||
Method method = AttrsXmlParser.class.getDeclaredMethod("getDocument"); //$NON-NLS-1$
|
||||
method.setAccessible(true);
|
||||
return (Document) method.invoke(mParser);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package com.android.ide.eclipse.editors.descriptors;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Unit tests for DescriptorsUtils in the editors plugin
|
||||
*/
|
||||
public class DescriptorsUtilsTest extends TestCase {
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testPrettyAttributeUiName() {
|
||||
assertEquals("", DescriptorsUtils.prettyAttributeUiName(""));
|
||||
|
||||
assertEquals("Max width for view",
|
||||
DescriptorsUtils.prettyAttributeUiName("maxWidthForView"));
|
||||
|
||||
assertEquals("Layout width",
|
||||
DescriptorsUtils.prettyAttributeUiName("layout_width"));
|
||||
|
||||
// X Y and Z are capitalized when used as single words (so "T" becomes "t")
|
||||
assertEquals("Axis X", DescriptorsUtils.prettyAttributeUiName("axisX"));
|
||||
assertEquals("Axis Y", DescriptorsUtils.prettyAttributeUiName("axisY"));
|
||||
assertEquals("Axis Z", DescriptorsUtils.prettyAttributeUiName("axisZ"));
|
||||
assertEquals("Axis t", DescriptorsUtils.prettyAttributeUiName("axisT"));
|
||||
|
||||
assertEquals("The X axis", DescriptorsUtils.prettyAttributeUiName("theXAxis"));
|
||||
assertEquals("The Y axis", DescriptorsUtils.prettyAttributeUiName("theYAxis"));
|
||||
assertEquals("The Z axis", DescriptorsUtils.prettyAttributeUiName("theZAxis"));
|
||||
assertEquals("The t axis", DescriptorsUtils.prettyAttributeUiName("theTAxis"));
|
||||
}
|
||||
|
||||
public void testCapitalize() {
|
||||
assertEquals("UPPER", DescriptorsUtils.capitalize("UPPER"));
|
||||
assertEquals("Lower", DescriptorsUtils.capitalize("lower"));
|
||||
assertEquals("Capital", DescriptorsUtils.capitalize("Capital"));
|
||||
assertEquals("CamelCase", DescriptorsUtils.capitalize("camelCase"));
|
||||
assertEquals("", DescriptorsUtils.capitalize(""));
|
||||
}
|
||||
|
||||
public void testFormatTooltip() {
|
||||
assertEquals("", DescriptorsUtils.formatTooltip(""));
|
||||
|
||||
assertEquals("\"application\"",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"<code>application</code>"));
|
||||
|
||||
assertEquals("android.content.Intent",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.content.Intent}"));
|
||||
|
||||
assertEquals("FLAG_ACTIVITY_SINGLE_TOP",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP}"));
|
||||
|
||||
assertEquals("activity-alias",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link \t #AndroidManifestActivityAlias \tactivity-alias }"));
|
||||
|
||||
assertEquals("\"permission\"",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link #AndroidManifestPermission <permission>}"));
|
||||
|
||||
assertEquals("and etc.",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link #IntentCategory <category> and etc. }"));
|
||||
|
||||
assertEquals("Activity.onNewIntent()",
|
||||
DescriptorsUtils.formatTooltip(
|
||||
"{@link android.app.Activity#onNewIntent Activity.onNewIntent()}"));
|
||||
}
|
||||
|
||||
public void testFormatFormText() {
|
||||
ElementDescriptor desc = new ElementDescriptor("application");
|
||||
desc.setSdkUrl(DescriptorsUtils.MANIFEST_SDK_URL + "TagApplication");
|
||||
String docBaseUrl = "http://base";
|
||||
assertEquals("<form><li style=\"image\" value=\"image\"></li></form>", DescriptorsUtils.formatFormText("", desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#TagApplication\">application</a></li></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"<code>application</code>",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><li style=\"image\" value=\"image\"><b>android.content.Intent</b></li></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link android.content.Intent}",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">AndroidManifestPermission</a></li></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link #AndroidManifestPermission}",
|
||||
desc, docBaseUrl));
|
||||
|
||||
assertEquals("<form><li style=\"image\" value=\"image\"><a href=\"http://base/reference/android/R.styleable.html#AndroidManifestPermission\">\"permission\"</a></li></form>",
|
||||
DescriptorsUtils.formatFormText(
|
||||
"{@link #AndroidManifestPermission <permission>}",
|
||||
desc, docBaseUrl));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.layout;
|
||||
|
||||
import com.android.ide.eclipse.editors.descriptors.AttributeDescriptor;
|
||||
import com.android.ide.eclipse.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.editors.descriptors.TextAttributeDescriptor;
|
||||
import com.android.ide.eclipse.editors.mock.MockXmlNode;
|
||||
import com.android.ide.eclipse.editors.uimodel.UiElementNode;
|
||||
import com.android.sdklib.SdkConstants;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class UiElementPullParserTest extends TestCase {
|
||||
|
||||
private UiElementNode ui;
|
||||
private HashMap<String, String> button1Map;
|
||||
private HashMap<String, String> button2Map;
|
||||
private HashMap<String, String> textMap;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// set up some basic descriptors.
|
||||
// We have button, textview, linear layout, relative layout.
|
||||
// only the layouts have children (all 4 descriptors possible)
|
||||
// Also add some dummy attributes.
|
||||
ElementDescriptor buttonDescriptor = new ElementDescriptor("Button", "Button", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("name", "name", SdkConstants.NS_RESOURCES, ""),
|
||||
new TextAttributeDescriptor("text", "text", SdkConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] {}, false);
|
||||
|
||||
ElementDescriptor textDescriptor = new ElementDescriptor("TextView", "TextView", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("name", "name", SdkConstants.NS_RESOURCES, ""),
|
||||
new TextAttributeDescriptor("text", "text", SdkConstants.NS_RESOURCES, ""), },
|
||||
new ElementDescriptor[] {}, false);
|
||||
|
||||
ElementDescriptor linearDescriptor = new ElementDescriptor("LinearLayout", "Linear Layout",
|
||||
"", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("orientation", "orientation",
|
||||
SdkConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] { }, false);
|
||||
|
||||
ElementDescriptor relativeDescriptor = new ElementDescriptor("RelativeLayout",
|
||||
"Relative Layout", "", "",
|
||||
new AttributeDescriptor[] {
|
||||
new TextAttributeDescriptor("orientation", "orientation",
|
||||
SdkConstants.NS_RESOURCES, ""),
|
||||
},
|
||||
new ElementDescriptor[] { }, false);
|
||||
|
||||
ElementDescriptor[] a = new ElementDescriptor[] {
|
||||
buttonDescriptor, textDescriptor, linearDescriptor, relativeDescriptor
|
||||
};
|
||||
|
||||
linearDescriptor.setChildren(a);
|
||||
relativeDescriptor.setChildren(a);
|
||||
|
||||
// document descriptor
|
||||
ElementDescriptor rootDescriptor = new ElementDescriptor("root", "", "", "",
|
||||
new AttributeDescriptor[] { }, a, false);
|
||||
|
||||
|
||||
ui = new UiElementNode(rootDescriptor);
|
||||
|
||||
/* create a dummy XML file.
|
||||
* <LinearLayout android:orientation="vertical">
|
||||
* <Button android:name="button1" android:text="button1text"/>
|
||||
* <RelativeLayout android:orientation="toto">
|
||||
* <Button android:name="button2" android:text="button2text"/>
|
||||
* <TextView android:name="text1" android:text="text1text"/>
|
||||
* </RelativeLayout>
|
||||
* </LinearLayout>
|
||||
*/
|
||||
MockXmlNode button1 = new MockXmlNode(null /* namespace */, "Button", Node.ELEMENT_NODE,
|
||||
null);
|
||||
button1.addAttributes(SdkConstants.NS_RESOURCES, "name", "button1");
|
||||
button1.addAttributes(SdkConstants.NS_RESOURCES, "text", "button1text");
|
||||
|
||||
// create a map of the attributes we add to the multi-attribute nodes so that
|
||||
// we can more easily test the values when we parse the XML.
|
||||
// This is due to some attributes showing in a certain order for a node and in a different
|
||||
// order in another node. Since the order doesn't matter, we just simplify the test.
|
||||
button1Map = new HashMap<String, String>();
|
||||
button1Map.put("name", "button1");
|
||||
button1Map.put("text", "button1text");
|
||||
|
||||
MockXmlNode button2 = new MockXmlNode(null /* namespace */, "Button", Node.ELEMENT_NODE,
|
||||
null);
|
||||
button2.addAttributes(SdkConstants.NS_RESOURCES, "name", "button2");
|
||||
button2.addAttributes(SdkConstants.NS_RESOURCES, "text", "button2text");
|
||||
|
||||
button2Map = new HashMap<String, String>();
|
||||
button2Map.put("name", "button2");
|
||||
button2Map.put("text", "button2text");
|
||||
|
||||
MockXmlNode text = new MockXmlNode(null /* namespace */, "TextView", Node.ELEMENT_NODE,
|
||||
null);
|
||||
text.addAttributes(SdkConstants.NS_RESOURCES, "name", "text1");
|
||||
text.addAttributes(SdkConstants.NS_RESOURCES, "text", "text1text");
|
||||
|
||||
textMap = new HashMap<String, String>();
|
||||
textMap.put("name", "text1");
|
||||
textMap.put("text", "text1text");
|
||||
|
||||
MockXmlNode relative = new MockXmlNode(null /* namespace */, "RelativeLayout",
|
||||
Node.ELEMENT_NODE, new MockXmlNode[] { button2, text });
|
||||
relative.addAttributes(SdkConstants.NS_RESOURCES, "orientation", "toto");
|
||||
|
||||
MockXmlNode linear = new MockXmlNode(null /* namespace */, "LinearLayout",
|
||||
Node.ELEMENT_NODE, new MockXmlNode[] { button1, relative });
|
||||
linear.addAttributes(SdkConstants.NS_RESOURCES, "orientation", "vertical");
|
||||
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "root", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] { linear });
|
||||
|
||||
// put the namespace/prefix in place
|
||||
root.setPrefix(SdkConstants.NS_RESOURCES, "android");
|
||||
|
||||
// load the xml into the UiElementNode
|
||||
ui.loadFromXmlNode(root);
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testParser() {
|
||||
try {
|
||||
// wrap the parser around the ui element node, and start parsing
|
||||
UiElementPullParser parser = new UiElementPullParser(ui);
|
||||
|
||||
assertEquals(XmlPullParser.START_DOCUMENT, parser.getEventType());
|
||||
|
||||
// top level Linear layout
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("LinearLayout", parser.getName());
|
||||
assertEquals(1, parser.getAttributeCount());
|
||||
assertEquals("orientation", parser.getAttributeName(0));
|
||||
assertEquals(SdkConstants.NS_RESOURCES, parser.getAttributeNamespace(0));
|
||||
assertEquals("android", parser.getAttributePrefix(0));
|
||||
assertEquals("vertical", parser.getAttributeValue(0));
|
||||
|
||||
// Button
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("Button", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, button1Map);
|
||||
check(parser, 1, button1Map);
|
||||
// end of button
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// Relative Layout
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("RelativeLayout", parser.getName());
|
||||
assertEquals(1, parser.getAttributeCount());
|
||||
assertEquals("orientation", parser.getAttributeName(0));
|
||||
assertEquals(SdkConstants.NS_RESOURCES, parser.getAttributeNamespace(0));
|
||||
assertEquals("android", parser.getAttributePrefix(0));
|
||||
assertEquals("toto", parser.getAttributeValue(0));
|
||||
|
||||
// Button
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("Button", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, button2Map);
|
||||
check(parser, 1, button2Map);
|
||||
// end of button
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// TextView
|
||||
assertEquals(XmlPullParser.START_TAG, parser.next());
|
||||
assertEquals("TextView", parser.getName());
|
||||
assertEquals(2, parser.getAttributeCount());
|
||||
check(parser, 0, textMap);
|
||||
check(parser, 1, textMap);
|
||||
// end of TextView
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
// end of RelativeLayout
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
|
||||
// end of top level linear layout
|
||||
assertEquals(XmlPullParser.END_TAG, parser.next());
|
||||
|
||||
assertEquals(XmlPullParser.END_DOCUMENT, parser.next());
|
||||
} catch (XmlPullParserException e) {
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a {@link XmlPullParser} at the START_TAG level, and checks the i-th attribute
|
||||
* to be present in the {@link HashMap} with the proper (name, value)
|
||||
* @param parser
|
||||
* @param i
|
||||
* @param map
|
||||
*/
|
||||
private void check(UiElementPullParser parser, int i, HashMap<String, String> map) {
|
||||
String name = parser.getAttributeName(i);
|
||||
String value = parser.getAttributeValue(i);
|
||||
|
||||
String referenceValue = map.get(name);
|
||||
assertNotNull(referenceValue);
|
||||
assertEquals(referenceValue, value);
|
||||
|
||||
assertEquals(SdkConstants.NS_RESOURCES, parser.getAttributeNamespace(i));
|
||||
assertEquals("android", parser.getAttributePrefix(i));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.manifest.model;
|
||||
|
||||
import com.android.ide.eclipse.editors.descriptors.ElementDescriptor;
|
||||
import com.android.ide.eclipse.editors.mock.MockXmlNode;
|
||||
import com.android.ide.eclipse.editors.uimodel.UiElementNode;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class UiElementNodeTest extends TestCase {
|
||||
|
||||
private ElementDescriptor e;
|
||||
private UiElementNode ui;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
e = new ElementDescriptor("manifest", new ElementDescriptor[] {
|
||||
new ElementDescriptor("application", new ElementDescriptor[] {
|
||||
new ElementDescriptor("provider"),
|
||||
new ElementDescriptor("activity", new ElementDescriptor[] {
|
||||
new ElementDescriptor("intent-filter")
|
||||
}),
|
||||
}),
|
||||
new ElementDescriptor("permission")
|
||||
});
|
||||
|
||||
ui = new UiElementNode(e);
|
||||
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
// pass
|
||||
}
|
||||
|
||||
/**
|
||||
* Check initialization values for ui node
|
||||
*/
|
||||
public void testInit() {
|
||||
assertSame(e, ui.getDescriptor());
|
||||
assertNull(ui.getUiParent());
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* loadFrom() does nothing if the root node doesn't match what's expected
|
||||
*/
|
||||
public void testLoadFrom_InvalidRoot() {
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "blah", Node.ELEMENT_NODE, null);
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals(0, ui.getUiChildren().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* UiElementNode.loadFrom should be used to populate an empty ui node from an
|
||||
* existing XML node tree.
|
||||
*/
|
||||
public void testLoadFrom_NewTree_1_Node() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE, null)
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(1, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(0, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
}
|
||||
|
||||
|
||||
public void testLoadFrom_NewTree_2_Nodes() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE, null),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE, null),
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(2, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(0, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission
|
||||
UiElementNode first_permission = ui_child_it.next();
|
||||
assertEquals("permission", first_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_permission.getUiChildren().size());
|
||||
assertEquals(0, first_permission.getUiAttributes().size());
|
||||
}
|
||||
|
||||
public void testLoadFrom_NewTree_N_Nodes() {
|
||||
MockXmlNode root = new MockXmlNode(null /* namespace */, "manifest", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "application", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "activity", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "activity", Node.ELEMENT_NODE,
|
||||
new MockXmlNode[] {
|
||||
new MockXmlNode(null /* namespace */, "intent-filter",
|
||||
Node.ELEMENT_NODE, null),
|
||||
}),
|
||||
new MockXmlNode(null /* namespace */, "provider", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "provider", Node.ELEMENT_NODE,
|
||||
null),
|
||||
}),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE,
|
||||
null),
|
||||
new MockXmlNode(null /* namespace */, "permission", Node.ELEMENT_NODE,
|
||||
null),
|
||||
});
|
||||
|
||||
// get /manifest
|
||||
ui.loadFromXmlNode(root);
|
||||
assertEquals("manifest", ui.getDescriptor().getXmlName());
|
||||
assertEquals(3, ui.getUiChildren().size());
|
||||
assertEquals(0, ui.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application
|
||||
Iterator<UiElementNode> ui_child_it = ui.getUiChildren().iterator();
|
||||
UiElementNode application = ui_child_it.next();
|
||||
assertEquals("application", application.getDescriptor().getXmlName());
|
||||
assertEquals(4, application.getUiChildren().size());
|
||||
assertEquals(0, application.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #1
|
||||
Iterator<UiElementNode> app_child_it = application.getUiChildren().iterator();
|
||||
UiElementNode first_activity = app_child_it.next();
|
||||
assertEquals("activity", first_activity.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_activity.getUiChildren().size());
|
||||
assertEquals(0, first_activity.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #2
|
||||
UiElementNode second_activity = app_child_it.next();
|
||||
assertEquals("activity", second_activity.getDescriptor().getXmlName());
|
||||
assertEquals(1, second_activity.getUiChildren().size());
|
||||
assertEquals(0, second_activity.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/activity #2/intent-filter #1
|
||||
Iterator<UiElementNode> activity_child_it = second_activity.getUiChildren().iterator();
|
||||
UiElementNode intent_filter = activity_child_it.next();
|
||||
assertEquals("intent-filter", intent_filter.getDescriptor().getXmlName());
|
||||
assertEquals(0, intent_filter.getUiChildren().size());
|
||||
assertEquals(0, intent_filter.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/provider #1
|
||||
UiElementNode first_provider = app_child_it.next();
|
||||
assertEquals("provider", first_provider.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_provider.getUiChildren().size());
|
||||
assertEquals(0, first_provider.getUiAttributes().size());
|
||||
|
||||
// get /manifest/application/provider #2
|
||||
UiElementNode second_provider = app_child_it.next();
|
||||
assertEquals("provider", second_provider.getDescriptor().getXmlName());
|
||||
assertEquals(0, second_provider.getUiChildren().size());
|
||||
assertEquals(0, second_provider.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission #1
|
||||
UiElementNode first_permission = ui_child_it.next();
|
||||
assertEquals("permission", first_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, first_permission.getUiChildren().size());
|
||||
assertEquals(0, first_permission.getUiAttributes().size());
|
||||
|
||||
// get /manifest/permission #1
|
||||
UiElementNode second_permission = ui_child_it.next();
|
||||
assertEquals("permission", second_permission.getDescriptor().getXmlName());
|
||||
assertEquals(0, second_permission.getUiChildren().size());
|
||||
assertEquals(0, second_permission.getUiAttributes().size());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.mock;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
class MockNamedNodeMap implements NamedNodeMap {
|
||||
|
||||
/** map for access by namespace/name */
|
||||
private final HashMap<String, HashMap<String, Node>> mNodeMap =
|
||||
new HashMap<String, HashMap<String, Node>>();
|
||||
|
||||
/** list for access by index */
|
||||
private final ArrayList<Node> mNodeList = new ArrayList<Node>();
|
||||
|
||||
public MockXmlNode addAttribute(String namespace, String localName, String value) {
|
||||
MockXmlNode node = new MockXmlNode(namespace, localName, value);
|
||||
|
||||
if (namespace == null) {
|
||||
namespace = ""; // no namespace
|
||||
}
|
||||
|
||||
// get the map for the namespace
|
||||
HashMap<String, Node> map = mNodeMap.get(namespace);
|
||||
if (map == null) {
|
||||
map = new HashMap<String, Node>();
|
||||
mNodeMap.put(namespace, map);
|
||||
}
|
||||
|
||||
|
||||
map.put(localName, node);
|
||||
mNodeList.add(node);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// --------- NamedNodeMap -------
|
||||
|
||||
public int getLength() {
|
||||
return mNodeList.size();
|
||||
}
|
||||
|
||||
public Node getNamedItem(String name) {
|
||||
HashMap<String, Node> map = mNodeMap.get(""); // no namespace
|
||||
if (map != null) {
|
||||
return map.get(name);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getNamedItemNS(String namespaceURI, String localName) throws DOMException {
|
||||
if (namespaceURI == null) {
|
||||
namespaceURI = ""; //no namespace
|
||||
}
|
||||
|
||||
HashMap<String, Node> map = mNodeMap.get(namespaceURI);
|
||||
if (map != null) {
|
||||
return map.get(localName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node item(int index) {
|
||||
return mNodeList.get(index);
|
||||
}
|
||||
|
||||
public Node removeNamedItem(String name) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node removeNamedItemNS(String namespaceURI, String localName) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node setNamedItem(Node arg) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node setNamedItemNS(Node arg) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.mock;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* A quick mock implementation of NodeList on top of ArrayList.
|
||||
*/
|
||||
public class MockNodeList implements NodeList {
|
||||
|
||||
ArrayList<MockXmlNode> mChildren;
|
||||
|
||||
/**
|
||||
* Constructs a node list from a given children list.
|
||||
*
|
||||
* @param children The children list. Can be null.
|
||||
*/
|
||||
public MockNodeList(MockXmlNode[] children) {
|
||||
mChildren = new ArrayList<MockXmlNode>();
|
||||
if (children != null) {
|
||||
for (MockXmlNode n : children) {
|
||||
mChildren.add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return mChildren.size();
|
||||
}
|
||||
|
||||
public Node item(int index) {
|
||||
if (index >= 0 && index < mChildren.size()) {
|
||||
return mChildren.get(index);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<MockXmlNode> getArrayList() {
|
||||
return mChildren;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.mock;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
|
||||
/**
|
||||
* A mock XML node with only a minimal set of information.
|
||||
*/
|
||||
public class MockXmlNode implements Node {
|
||||
|
||||
MockNodeList mNodeList;
|
||||
private String mLocalName;
|
||||
private String mNamespace;
|
||||
private short mNodeType;
|
||||
private MockXmlNode mParent;
|
||||
private MockXmlNode mPreviousSibling;
|
||||
private MockXmlNode mNextSibling;
|
||||
private String mAttrValue;
|
||||
private MockNamedNodeMap mAttributes;
|
||||
|
||||
// namespace stuff only set in the root node
|
||||
/** map from namespace to prefix. */
|
||||
private HashMap<String, String> mNsMap = null;
|
||||
|
||||
/**
|
||||
* Constructs a node from a given children list.
|
||||
*
|
||||
* @param namespace The namespace of the node or null if none
|
||||
* @param localName The XML local node name.
|
||||
* @param node_type One of Node.xxx_NODE constants, e.g. Node.ELEMENT_NODE
|
||||
* @param children The children list. Can be null.
|
||||
*/
|
||||
public MockXmlNode(String namespace, String localName, short node_type,
|
||||
MockXmlNode[] children) {
|
||||
mLocalName = localName;
|
||||
mNamespace = namespace;
|
||||
mNodeType = node_type;
|
||||
mNodeList = new MockNodeList(children);
|
||||
fixNavigation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an attribute node
|
||||
*
|
||||
* @param namespace The namespace of the node or null if none
|
||||
* @param localName The XML local node name.
|
||||
* @param value the value of the attribute
|
||||
*/
|
||||
public MockXmlNode(String namespace, String localName, String value) {
|
||||
mLocalName = localName;
|
||||
mNamespace = namespace;
|
||||
mAttrValue = value;
|
||||
mNodeType = Node.ATTRIBUTE_NODE;
|
||||
mNodeList = new MockNodeList(new MockXmlNode[0]);
|
||||
fixNavigation();
|
||||
}
|
||||
|
||||
private void fixNavigation() {
|
||||
MockXmlNode prev = null;
|
||||
for (MockXmlNode n : mNodeList.getArrayList()) {
|
||||
n.mParent = this;
|
||||
n.mPreviousSibling = prev;
|
||||
if (prev != null) {
|
||||
prev.mNextSibling = n;
|
||||
}
|
||||
n.fixNavigation();
|
||||
prev = n;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAttributes(String namespaceURI, String localName, String value) {
|
||||
if (mAttributes == null) {
|
||||
mAttributes = new MockNamedNodeMap();
|
||||
}
|
||||
|
||||
MockXmlNode node = mAttributes.addAttribute(namespaceURI, localName, value);
|
||||
node.mParent = this;
|
||||
}
|
||||
|
||||
public void setPrefix(String namespace, String prefix) {
|
||||
if (mNsMap == null) {
|
||||
mNsMap = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
mNsMap.put(namespace, prefix);
|
||||
}
|
||||
|
||||
public String getPrefix(String namespace) {
|
||||
if (mNsMap != null) {
|
||||
return mNsMap.get(namespace);
|
||||
}
|
||||
|
||||
return mParent.getPrefix(namespace);
|
||||
}
|
||||
|
||||
|
||||
// ----------- Node methods
|
||||
|
||||
public Node appendChild(Node newChild) throws DOMException {
|
||||
mNodeList.getArrayList().add((MockXmlNode) newChild);
|
||||
return newChild;
|
||||
}
|
||||
|
||||
public NamedNodeMap getAttributes() {
|
||||
return mAttributes;
|
||||
}
|
||||
|
||||
public NodeList getChildNodes() {
|
||||
return mNodeList;
|
||||
}
|
||||
|
||||
public Node getFirstChild() {
|
||||
if (mNodeList.getLength() > 0) {
|
||||
return mNodeList.item(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getLastChild() {
|
||||
if (mNodeList.getLength() > 0) {
|
||||
return mNodeList.item(mNodeList.getLength() - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Node getNextSibling() {
|
||||
return mNextSibling;
|
||||
}
|
||||
|
||||
public String getNodeName() {
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public String getLocalName() {
|
||||
return mLocalName;
|
||||
}
|
||||
|
||||
public short getNodeType() {
|
||||
return mNodeType;
|
||||
}
|
||||
|
||||
public Node getParentNode() {
|
||||
return mParent;
|
||||
}
|
||||
|
||||
public Node getPreviousSibling() {
|
||||
return mPreviousSibling;
|
||||
}
|
||||
|
||||
public boolean hasChildNodes() {
|
||||
return mNodeList.getLength() > 0;
|
||||
}
|
||||
|
||||
public boolean hasAttributes() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new NotImplementedException();
|
||||
//return false;
|
||||
}
|
||||
|
||||
public boolean isSameNode(Node other) {
|
||||
return this == other;
|
||||
}
|
||||
|
||||
public String getNodeValue() throws DOMException {
|
||||
return mAttrValue;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return getPrefix(getNamespaceURI());
|
||||
}
|
||||
|
||||
public String getNamespaceURI() {
|
||||
return mNamespace;
|
||||
}
|
||||
|
||||
|
||||
// --- methods not implemented ---
|
||||
|
||||
public Node cloneNode(boolean deep) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public short compareDocumentPosition(Node other) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getBaseURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getFeature(String feature, String version) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Document getOwnerDocument() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getTextContent() throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getUserData(String key) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node insertBefore(Node newChild, Node refChild)
|
||||
throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDefaultNamespace(String namespaceURI) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isEqualNode(Node arg) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSupported(String feature, String version) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String lookupNamespaceURI(String prefix) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String lookupPrefix(String namespaceURI) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void normalize() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node removeChild(Node oldChild) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Node replaceChild(Node newChild, Node oldChild)
|
||||
throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setNodeValue(String nodeValue) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTextContent(String textContent) throws DOMException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object setUserData(String key, Object data,
|
||||
UserDataHandler handler) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class CountryCodeQualifierTest extends TestCase {
|
||||
|
||||
private CountryCodeQualifier mccq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mccq = new CountryCodeQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
mccq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, mccq.checkAndSet("mcc123", config));//$NON-NLS-1$
|
||||
assertTrue(config.getCountryCodeQualifier() != null);
|
||||
assertEquals(123, config.getCountryCodeQualifier().getCode());
|
||||
assertEquals("mcc123", config.getCountryCodeQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, mccq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, mccq.checkAndSet("mcc", config));//$NON-NLS-1$
|
||||
assertEquals(false, mccq.checkAndSet("MCC123", config));//$NON-NLS-1$
|
||||
assertEquals(false, mccq.checkAndSet("123", config));//$NON-NLS-1$
|
||||
assertEquals(false, mccq.checkAndSet("mccsdf", config));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class KeyboardStateQualifierTest extends TestCase {
|
||||
|
||||
private KeyboardStateQualifier ksq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
ksq = new KeyboardStateQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
ksq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testExposed() {
|
||||
assertEquals(true, ksq.checkAndSet("keysexposed", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getKeyboardStateQualifier() != null);
|
||||
assertEquals(KeyboardStateQualifier.KeyboardState.EXPOSED,
|
||||
config.getKeyboardStateQualifier().getValue());
|
||||
assertEquals("keysexposed", config.getKeyboardStateQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testHidden() {
|
||||
assertEquals(true, ksq.checkAndSet("keyshidden", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getKeyboardStateQualifier() != null);
|
||||
assertEquals(KeyboardStateQualifier.KeyboardState.HIDDEN,
|
||||
config.getKeyboardStateQualifier().getValue());
|
||||
assertEquals("keyshidden", config.getKeyboardStateQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, ksq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, ksq.checkAndSet("KEYSEXPOSED", config));//$NON-NLS-1$
|
||||
assertEquals(false, ksq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class LanguageQualifierTest extends TestCase {
|
||||
|
||||
private FolderConfiguration config;
|
||||
private LanguageQualifier lq;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
config = new FolderConfiguration();
|
||||
lq = new LanguageQualifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
config = null;
|
||||
lq = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, lq.checkAndSet("en", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getLanguageQualifier() != null);
|
||||
assertEquals("en", config.getLanguageQualifier().toString()); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, lq.checkAndSet("", config)); //$NON-NLS-1$
|
||||
assertEquals(false, lq.checkAndSet("EN", config)); //$NON-NLS-1$
|
||||
assertEquals(false, lq.checkAndSet("abc", config)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class NavigationMethodQualifierTest extends TestCase {
|
||||
|
||||
private FolderConfiguration config;
|
||||
private NavigationMethodQualifier nmq;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
config = new FolderConfiguration();
|
||||
nmq = new NavigationMethodQualifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
config = null;
|
||||
nmq = null;
|
||||
}
|
||||
|
||||
public void testDPad() {
|
||||
assertEquals(true, nmq.checkAndSet("dpad", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getNavigationMethodQualifier() != null);
|
||||
assertEquals(NavigationMethodQualifier.NavigationMethod.DPAD,
|
||||
config.getNavigationMethodQualifier().getValue());
|
||||
assertEquals("dpad", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testTrackball() {
|
||||
assertEquals(true, nmq.checkAndSet("trackball", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getNavigationMethodQualifier() != null);
|
||||
assertEquals(NavigationMethodQualifier.NavigationMethod.TRACKBALL,
|
||||
config.getNavigationMethodQualifier().getValue());
|
||||
assertEquals("trackball", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testWheel() {
|
||||
assertEquals(true, nmq.checkAndSet("wheel", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getNavigationMethodQualifier() != null);
|
||||
assertEquals(NavigationMethodQualifier.NavigationMethod.WHEEL,
|
||||
config.getNavigationMethodQualifier().getValue());
|
||||
assertEquals("wheel", config.getNavigationMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, nmq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, nmq.checkAndSet("WHEEL", config));//$NON-NLS-1$
|
||||
assertEquals(false, nmq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class NetworkCodeQualifierTest extends TestCase {
|
||||
|
||||
private NetworkCodeQualifier mncq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mncq = new NetworkCodeQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
mncq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, mncq.checkAndSet("mnc123", config));//$NON-NLS-1$
|
||||
assertTrue(config.getNetworkCodeQualifier() != null);
|
||||
assertEquals(123, config.getNetworkCodeQualifier().getCode());
|
||||
assertEquals("mnc123", config.getNetworkCodeQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, mncq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, mncq.checkAndSet("mnc", config));//$NON-NLS-1$
|
||||
assertEquals(false, mncq.checkAndSet("MNC123", config));//$NON-NLS-1$
|
||||
assertEquals(false, mncq.checkAndSet("123", config));//$NON-NLS-1$
|
||||
assertEquals(false, mncq.checkAndSet("mncsdf", config));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class PixelDensityQualifierTest extends TestCase {
|
||||
|
||||
private PixelDensityQualifier pdq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
pdq = new PixelDensityQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
pdq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, pdq.checkAndSet("123dpi", config));//$NON-NLS-1$
|
||||
assertTrue(config.getPixelDensityQualifier() != null);
|
||||
assertEquals(123, config.getPixelDensityQualifier().getValue());
|
||||
assertEquals("123dpi", config.getPixelDensityQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, pdq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("dpi", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("123DPI", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("123", config));//$NON-NLS-1$
|
||||
assertEquals(false, pdq.checkAndSet("sdfdpi", config));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class RegionQualifierTest extends TestCase {
|
||||
|
||||
private RegionQualifier rq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
rq = new RegionQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
rq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, rq.checkAndSet("rUS", config));//$NON-NLS-1$
|
||||
assertTrue(config.getRegionQualifier() != null);
|
||||
assertEquals("US", config.getRegionQualifier().getValue()); //$NON-NLS-1$
|
||||
assertEquals("rUS", config.getRegionQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, rq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, rq.checkAndSet("rus", config));//$NON-NLS-1$
|
||||
assertEquals(false, rq.checkAndSet("rUSA", config));//$NON-NLS-1$
|
||||
assertEquals(false, rq.checkAndSet("abc", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ScreenDimensionQualifierTest extends TestCase {
|
||||
|
||||
private ScreenDimensionQualifier sdq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
sdq = new ScreenDimensionQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
sdq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testCheckAndSet() {
|
||||
assertEquals(true, sdq.checkAndSet("400x200", config));//$NON-NLS-1$
|
||||
assertTrue(config.getScreenDimensionQualifier() != null);
|
||||
assertEquals(400, config.getScreenDimensionQualifier().getValue1());
|
||||
assertEquals(200, config.getScreenDimensionQualifier().getValue2());
|
||||
assertEquals("400x200", config.getScreenDimensionQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, sdq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("400X200", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("x200", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("ax200", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("400x", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("400xa", config));//$NON-NLS-1$
|
||||
assertEquals(false, sdq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ScreenOrientationQualifierTest extends TestCase {
|
||||
|
||||
private ScreenOrientationQualifier soq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
soq = new ScreenOrientationQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
soq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testPortrait() {
|
||||
assertEquals(true, soq.checkAndSet("port", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getScreenOrientationQualifier() != null);
|
||||
assertEquals(ScreenOrientationQualifier.ScreenOrientation.PORTRAIT,
|
||||
config.getScreenOrientationQualifier().getValue());
|
||||
assertEquals("port", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testLanscape() {
|
||||
assertEquals(true, soq.checkAndSet("land", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getScreenOrientationQualifier() != null);
|
||||
assertEquals(ScreenOrientationQualifier.ScreenOrientation.LANDSCAPE,
|
||||
config.getScreenOrientationQualifier().getValue());
|
||||
assertEquals("land", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testSquare() {
|
||||
assertEquals(true, soq.checkAndSet("square", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getScreenOrientationQualifier() != null);
|
||||
assertEquals(ScreenOrientationQualifier.ScreenOrientation.SQUARE,
|
||||
config.getScreenOrientationQualifier().getValue());
|
||||
assertEquals("square", config.getScreenOrientationQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, soq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, soq.checkAndSet("PORT", config));//$NON-NLS-1$
|
||||
assertEquals(false, soq.checkAndSet("landscape", config));//$NON-NLS-1$
|
||||
assertEquals(false, soq.checkAndSet("portrait", config));//$NON-NLS-1$
|
||||
assertEquals(false, soq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TextInputMethodQualifierTest extends TestCase {
|
||||
|
||||
private TextInputMethodQualifier timq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
timq = new TextInputMethodQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
timq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testQuerty() {
|
||||
assertEquals(true, timq.checkAndSet("qwerty", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTextInputMethodQualifier() != null);
|
||||
assertEquals(TextInputMethodQualifier.TextInputMethod.QWERTY,
|
||||
config.getTextInputMethodQualifier().getValue());
|
||||
assertEquals("qwerty", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void test12Key() {
|
||||
assertEquals(true, timq.checkAndSet("12key", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTextInputMethodQualifier() != null);
|
||||
assertEquals(TextInputMethodQualifier.TextInputMethod.TWELVEKEYS,
|
||||
config.getTextInputMethodQualifier().getValue());
|
||||
assertEquals("12key", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testNoKey() {
|
||||
assertEquals(true, timq.checkAndSet("nokeys", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTextInputMethodQualifier() != null);
|
||||
assertEquals(TextInputMethodQualifier.TextInputMethod.NOKEY,
|
||||
config.getTextInputMethodQualifier().getValue());
|
||||
assertEquals("nokeys", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, timq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, timq.checkAndSet("QWERTY", config));//$NON-NLS-1$
|
||||
assertEquals(false, timq.checkAndSet("12keys", config));//$NON-NLS-1$
|
||||
assertEquals(false, timq.checkAndSet("*12key", config));//$NON-NLS-1$
|
||||
assertEquals(false, timq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.configurations;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class TouchScreenQualifierTest extends TestCase {
|
||||
|
||||
private TouchScreenQualifier tsq;
|
||||
private FolderConfiguration config;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
tsq = new TouchScreenQualifier();
|
||||
config = new FolderConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
tsq = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public void testNoTouch() {
|
||||
assertEquals(true, tsq.checkAndSet("notouch", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTouchTypeQualifier() != null);
|
||||
assertEquals(TouchScreenQualifier.TouchScreenType.NOTOUCH,
|
||||
config.getTouchTypeQualifier().getValue());
|
||||
assertEquals("notouch", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFinger() {
|
||||
assertEquals(true, tsq.checkAndSet("finger", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTouchTypeQualifier() != null);
|
||||
assertEquals(TouchScreenQualifier.TouchScreenType.FINGER,
|
||||
config.getTouchTypeQualifier().getValue());
|
||||
assertEquals("finger", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testStylus() {
|
||||
assertEquals(true, tsq.checkAndSet("stylus", config)); //$NON-NLS-1$
|
||||
assertTrue(config.getTouchTypeQualifier() != null);
|
||||
assertEquals(TouchScreenQualifier.TouchScreenType.STYLUS,
|
||||
config.getTouchTypeQualifier().getValue());
|
||||
assertEquals("stylus", config.getTouchTypeQualifier().toString()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testFailures() {
|
||||
assertEquals(false, tsq.checkAndSet("", config));//$NON-NLS-1$
|
||||
assertEquals(false, tsq.checkAndSet("STYLUS", config));//$NON-NLS-1$
|
||||
assertEquals(false, tsq.checkAndSet("other", config));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.manager;
|
||||
|
||||
import com.android.ide.eclipse.editors.resources.configurations.FolderConfiguration;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.KeyboardStateQualifier.KeyboardState;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.NavigationMethodQualifier.NavigationMethod;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ScreenOrientationQualifier.ScreenOrientation;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.TextInputMethodQualifier.TextInputMethod;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.TouchScreenQualifier.TouchScreenType;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IAbstractFolder;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IFileWrapper;
|
||||
import com.android.ide.eclipse.editors.resources.manager.files.IFolderWrapper;
|
||||
import com.android.ide.eclipse.mock.FileMock;
|
||||
import com.android.ide.eclipse.mock.FolderMock;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ConfigMatchTest extends TestCase {
|
||||
private static final String SEARCHED_FILENAME = "main.xml"; //$NON-NLS-1$
|
||||
private static final String MISC1_FILENAME = "foo.xml"; //$NON-NLS-1$
|
||||
private static final String MISC2_FILENAME = "bar.xml"; //$NON-NLS-1$
|
||||
|
||||
private ProjectResources mResources;
|
||||
private ResourceQualifier[] mQualifierList;
|
||||
private FolderConfiguration config4;
|
||||
private FolderConfiguration config3;
|
||||
private FolderConfiguration config2;
|
||||
private FolderConfiguration config1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
// create a Resource Manager to get a list of qualifier as instantiated by the real code.
|
||||
// Thanks for QualifierListTest we know this contains all the qualifiers.
|
||||
ResourceManager manager = ResourceManager.getInstance();
|
||||
Field qualifierListField = ResourceManager.class.getDeclaredField("mQualifiers");
|
||||
assertNotNull(qualifierListField);
|
||||
qualifierListField.setAccessible(true);
|
||||
|
||||
// get the actual list.
|
||||
mQualifierList = (ResourceQualifier[])qualifierListField.get(manager);
|
||||
|
||||
// create the project resources.
|
||||
mResources = new ProjectResources(false /* isFrameworkRepository */);
|
||||
|
||||
// create 2 arrays of IResource. one with the filename being looked up, and one without.
|
||||
// Since the required API uses IResource, we can use MockFolder for them.
|
||||
FileMock[] validMemberList = new FileMock[] {
|
||||
new FileMock(MISC1_FILENAME),
|
||||
new FileMock(SEARCHED_FILENAME),
|
||||
new FileMock(MISC2_FILENAME),
|
||||
};
|
||||
FileMock[] invalidMemberList = new FileMock[] {
|
||||
new FileMock(MISC1_FILENAME),
|
||||
new FileMock(MISC2_FILENAME),
|
||||
};
|
||||
|
||||
// add multiple ResourceFolder to the project resource.
|
||||
FolderConfiguration defaultConfig = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
null, // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
null, // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, defaultConfig, validMemberList);
|
||||
|
||||
config1 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config1, validMemberList);
|
||||
|
||||
config2 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
null, // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
KeyboardState.HIDDEN.getValue(), // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config2, validMemberList);
|
||||
|
||||
config3 = getConfiguration(
|
||||
null, // country code
|
||||
null, // network code
|
||||
"en", // language
|
||||
null, // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
null, // dpi
|
||||
null, // touch mode
|
||||
null, // keyboard state
|
||||
null, // text input
|
||||
null, // navigation
|
||||
null); // screen size
|
||||
|
||||
addFolder(mResources, config3, validMemberList);
|
||||
|
||||
config4 = getConfiguration(
|
||||
"mcc310", // country code
|
||||
"mnc435", // network code
|
||||
"en", // language
|
||||
"rUS", // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
"160dpi", // dpi
|
||||
TouchScreenType.FINGER.getValue(), // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
TextInputMethod.QWERTY.getValue(), // text input
|
||||
NavigationMethod.DPAD.getValue(), // navigation
|
||||
"480x320"); // screen size
|
||||
|
||||
addFolder(mResources, config4, invalidMemberList);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
mResources = null;
|
||||
}
|
||||
|
||||
public void test1() {
|
||||
FolderConfiguration testConfig = getConfiguration(
|
||||
"mcc310", // country code
|
||||
"mnc435", // network code
|
||||
"en", // language
|
||||
"rUS", // region
|
||||
ScreenOrientation.LANDSCAPE.getValue(), // screen orientation
|
||||
"160dpi", // dpi
|
||||
TouchScreenType.FINGER.getValue(), // touch mode
|
||||
KeyboardState.EXPOSED.getValue(), // keyboard state
|
||||
TextInputMethod.QWERTY.getValue(), // text input
|
||||
NavigationMethod.DPAD.getValue(), // navigation
|
||||
"480x320"); // screen size
|
||||
|
||||
ResourceFile result = mResources.getMatchingFile(SEARCHED_FILENAME,
|
||||
ResourceFolderType.LAYOUT, testConfig);
|
||||
|
||||
boolean bresult = result.getFolder().getConfiguration().equals(config3);
|
||||
assertEquals(bresult, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FolderConfiguration}.
|
||||
* @param qualifierValues The list of qualifier values. The length must equals the total number
|
||||
* of Qualifiers. <code>null</code> is permitted and will make the FolderConfiguration not use
|
||||
* this particular qualifier.
|
||||
*/
|
||||
private FolderConfiguration getConfiguration(String... qualifierValues) {
|
||||
FolderConfiguration config = new FolderConfiguration();
|
||||
|
||||
// those must be of the same length
|
||||
assertEquals(qualifierValues.length, mQualifierList.length);
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (ResourceQualifier qualifier : mQualifierList) {
|
||||
String value = qualifierValues[index++];
|
||||
if (value != null) {
|
||||
assertTrue(qualifier.checkAndSet(value, config));
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a folder to the given {@link ProjectResources} with the given
|
||||
* {@link FolderConfiguration}. The folder is filled with files from the provided list.
|
||||
* @param resources the {@link ProjectResources} in which to add the folder.
|
||||
* @param config the {@link FolderConfiguration} for the created folder.
|
||||
* @param memberList the list of files for the folder.
|
||||
*/
|
||||
private void addFolder(ProjectResources resources, FolderConfiguration config,
|
||||
FileMock[] memberList) throws Exception {
|
||||
|
||||
// figure out the folder name based on the configuration
|
||||
String folderName = "layout";
|
||||
if (config.isDefault() == false) {
|
||||
folderName += "-" + config.toString();
|
||||
}
|
||||
|
||||
// create the folder mock
|
||||
FolderMock folder = new FolderMock(folderName, memberList);
|
||||
|
||||
// add it to the resource, and get back a ResourceFolder object.
|
||||
ResourceFolder resFolder = _addProjectResourceFolder(resources, config, folder);
|
||||
|
||||
// and fill it with files from the list.
|
||||
for (FileMock file : memberList) {
|
||||
resFolder.addFile(new SingleResourceFile(new IFileWrapper(file), resFolder));
|
||||
}
|
||||
}
|
||||
|
||||
/** Calls ProjectResource.add method via reflection to circumvent access
|
||||
* restrictions that are enforced when running in the plug-in environment
|
||||
* ie cannot access package or protected members in a different plug-in, even
|
||||
* if they are in the same declared package as the accessor
|
||||
*/
|
||||
private ResourceFolder _addProjectResourceFolder(ProjectResources resources,
|
||||
FolderConfiguration config, FolderMock folder) throws Exception {
|
||||
|
||||
Method addMethod = ProjectResources.class.getDeclaredMethod("add",
|
||||
ResourceFolderType.class, FolderConfiguration.class,
|
||||
IAbstractFolder.class);
|
||||
addMethod.setAccessible(true);
|
||||
ResourceFolder resFolder = (ResourceFolder)addMethod.invoke(resources,
|
||||
ResourceFolderType.LAYOUT, config, new IFolderWrapper(folder));
|
||||
return resFolder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.editors.resources.manager;
|
||||
|
||||
import com.android.ide.eclipse.editors.resources.configurations.FolderConfiguration;
|
||||
import com.android.ide.eclipse.editors.resources.configurations.ResourceQualifier;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class QualifierListTest extends TestCase {
|
||||
|
||||
private ResourceManager mManager;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
mManager = ResourceManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
mManager = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testQualifierList() {
|
||||
try {
|
||||
// get the list of qualifier in the resource manager
|
||||
Field qualifierListField = ResourceManager.class.getDeclaredField("mQualifiers");
|
||||
assertNotNull(qualifierListField);
|
||||
qualifierListField.setAccessible(true);
|
||||
|
||||
// get the actual list.
|
||||
ResourceQualifier[] qualifierList =
|
||||
(ResourceQualifier[])qualifierListField.get(mManager);
|
||||
|
||||
// now get the number of qualifier in the FolderConfiguration
|
||||
Field qualCountField = FolderConfiguration.class.getDeclaredField("INDEX_COUNT");
|
||||
assertNotNull(qualCountField);
|
||||
qualCountField.setAccessible(true);
|
||||
|
||||
// get the constant value
|
||||
Integer count = (Integer)qualCountField.get(null);
|
||||
|
||||
// now compare
|
||||
assertEquals(count.intValue(), qualifierList.length);
|
||||
} catch (SecurityException e) {
|
||||
assertTrue(false);
|
||||
} catch (NoSuchFieldException e) {
|
||||
assertTrue(false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertTrue(false);
|
||||
} catch (IllegalAccessException e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.mock;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jdt.core.IAccessRule;
|
||||
import org.eclipse.jdt.core.IClasspathAttribute;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
public class ClasspathEntryMock implements IClasspathEntry {
|
||||
|
||||
private int mKind;
|
||||
private IPath mPath;
|
||||
|
||||
public ClasspathEntryMock(IPath path, int kind) {
|
||||
mPath = path;
|
||||
mKind = kind;
|
||||
}
|
||||
|
||||
public int getEntryKind() {
|
||||
return mKind;
|
||||
}
|
||||
|
||||
public IPath getPath() {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public boolean combineAccessRules() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IAccessRule[] getAccessRules() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getContentKind() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath[] getExclusionPatterns() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathAttribute[] getExtraAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath[] getInclusionPatterns() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getOutputLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry getResolvedEntry() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getSourceAttachmentPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getSourceAttachmentRootPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isExported() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFileState;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.content.IContentDescription;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link IFile}.
|
||||
* <p/>Supported methods:
|
||||
* <ul>
|
||||
* </ul>
|
||||
*/
|
||||
public class FileMock implements IFile {
|
||||
|
||||
private String mName;
|
||||
|
||||
public FileMock(String name) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
// -------- MOCKED METHODS ----------------
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void appendContents(InputStream source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(InputStream source, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(URI location, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getCharsetFor(Reader reader) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContentDescription getContentDescription() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public InputStream getContents() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public InputStream getContents(boolean force) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getEncoding() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setCharset(String newCharset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(InputStream source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setContents(IFileState source, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
return new Path(mName);
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Mock implementation of {@link IFolder}.
|
||||
* <p/>Supported methods:
|
||||
* <ul>
|
||||
* <li>{@link #getName()}</li>
|
||||
* <li>{@link #members()}</li>
|
||||
* </ul>
|
||||
*/
|
||||
public final class FolderMock implements IFolder {
|
||||
|
||||
private String mName;
|
||||
private IResource[] mMembers;
|
||||
|
||||
public FolderMock(String name) {
|
||||
mName = name;
|
||||
mMembers = new IResource[0];
|
||||
}
|
||||
|
||||
public FolderMock(String name, IResource[] members) {
|
||||
mName = name;
|
||||
mMembers = members;
|
||||
}
|
||||
|
||||
// -------- MOCKED METHODS ----------------
|
||||
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
public IResource[] members() throws CoreException {
|
||||
return mMembers;
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public void create(boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(int updateFlags, boolean local, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void createLink(URI location, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(boolean includePhantoms) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.mock;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.jdt.core.IBuffer;
|
||||
import org.eclipse.jdt.core.IClasspathEntry;
|
||||
import org.eclipse.jdt.core.IJavaElement;
|
||||
import org.eclipse.jdt.core.IJavaModel;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.core.IOpenable;
|
||||
import org.eclipse.jdt.core.IPackageFragment;
|
||||
import org.eclipse.jdt.core.IPackageFragmentRoot;
|
||||
import org.eclipse.jdt.core.IRegion;
|
||||
import org.eclipse.jdt.core.IType;
|
||||
import org.eclipse.jdt.core.ITypeHierarchy;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
import org.eclipse.jdt.core.JavaModelException;
|
||||
import org.eclipse.jdt.core.WorkingCopyOwner;
|
||||
import org.eclipse.jdt.core.eval.IEvaluationContext;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class JavaProjectMock implements IJavaProject {
|
||||
|
||||
private IProject mProject;
|
||||
|
||||
private IClasspathEntry[] mEntries;
|
||||
private IPath mOutputLocation;
|
||||
private String mCompilerCompliance = "1.4"; //$NON-NLS-1
|
||||
private String mCompilerSource = "1.4"; //$NON-NLS-1
|
||||
private String mCompilerTarget = "1.4"; //$NON-NLS-1
|
||||
|
||||
public JavaProjectMock(IClasspathEntry[] entries, IPath outputLocation) {
|
||||
mEntries = entries;
|
||||
mOutputLocation = outputLocation;
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
if (mProject == null) {
|
||||
mProject = new ProjectMock();
|
||||
}
|
||||
|
||||
return mProject;
|
||||
}
|
||||
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
mEntries = entries;
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
mEntries = entries;
|
||||
mOutputLocation = outputLocation;
|
||||
}
|
||||
|
||||
public IClasspathEntry[] getRawClasspath() throws JavaModelException {
|
||||
return mEntries;
|
||||
}
|
||||
|
||||
public IPath getOutputLocation() throws JavaModelException {
|
||||
return mOutputLocation;
|
||||
}
|
||||
|
||||
public String getOption(String optionName, boolean inheritJavaCoreOptions) {
|
||||
if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
|
||||
return mCompilerCompliance;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
|
||||
return mCompilerSource;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
|
||||
return mCompilerTarget;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setOption(String optionName, String optionValue) {
|
||||
if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) {
|
||||
mCompilerCompliance = optionValue;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_SOURCE)) {
|
||||
mCompilerSource = optionValue;
|
||||
} else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) {
|
||||
mCompilerTarget = optionValue;
|
||||
} else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
public IClasspathEntry decodeClasspathEntry(String encodedEntry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String encodeClasspathEntry(IClasspathEntry classpathEntry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(IPath path, WorkingCopyOwner owner) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragment findPackageFragment(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot findPackageFragmentRoot(IPath path) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, IProgressMonitor progressMonitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String fullyQualifiedName, WorkingCopyOwner owner,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner,
|
||||
IProgressMonitor progressMonitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getAllPackageFragmentRoots() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object[] getNonJavaResources() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map getOptions(boolean inheritJavaCoreOptions) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot getPackageFragmentRoot(String jarPath) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getPackageFragmentRoots() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPackageFragment[] getPackageFragments() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String[] getRequiredProjectNames() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasBuildState() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasClasspathCycle(IClasspathEntry[] entries) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOnClasspath(IJavaElement element) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOnClasspath(IResource resource) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEvaluationContext newEvaluationContext() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath readOutputLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IClasspathEntry[] readRawClasspath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setOptions(Map newOptions) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setOutputLocation(IPath path, IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, boolean canModifyResources,
|
||||
IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation,
|
||||
boolean canModifyResources, IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement[] getChildren() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasChildren() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getAncestor(int ancestorType) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getCorrespondingResource() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getElementName() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getElementType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getHandleIdentifier() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaModel getJavaModel() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaProject getJavaProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IOpenable getOpenable() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement getPrimaryElement() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getResource() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ISchedulingRule getSchedulingRule() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource getUnderlyingResource() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isStructureKnown() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void close() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String findRecommendedLineSeparator() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IBuffer getBuffer() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasUnsavedChanges() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConsistent() throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void makeConsistent(IProgressMonitor progress) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(IProgressMonitor progress) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void save(IProgressMonitor progress, boolean force) throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IJavaElement findElement(String bindingKey, WorkingCopyOwner owner)
|
||||
throws JavaModelException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.mock;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceProxy;
|
||||
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||
import org.eclipse.core.resources.IResourceVisitor;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourceAttributes;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IPluginDescriptor;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.content.IContentTypeMatcher;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProjectMock implements IProject {
|
||||
|
||||
public void build(int kind, IProgressMonitor monitor) throws CoreException {
|
||||
// pass
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void build(int kind, String builderName, Map args, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
// pass
|
||||
}
|
||||
|
||||
// -------- UNIMPLEMENTED METHODS ----------------
|
||||
|
||||
|
||||
public void close(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProjectDescription description, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean deleteContent, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContentTypeMatcher getContentTypeMatcher() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProjectDescription getDescription() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProjectNature getNature(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public IPath getPluginWorkingLocation(IPluginDescriptor plugin) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject[] getReferencedProjects() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject[] getReferencingProjects() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getWorkingLocation(String id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean hasNature(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isNatureEnabled(String natureId) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void open(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDescription(IProjectDescription description, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDescription(IProjectDescription description, int updateFlags,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(String name, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource findMember(IPath path, boolean includePhantoms) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getDefaultCharset(boolean checkImplicit) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFile getFile(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IFolder getFolder(IPath path) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(boolean includePhantoms) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResource[] members(int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDefaultCharset(String charset, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void clearHistory(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker createMarker(String type) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IResourceProxy createProxy() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean exists() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker findMarker(long id) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getFileExtension() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getFullPath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getLocalTimeStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IMarker getMarker(long id) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long getModificationStamp() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IContainer getParent() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public String getPersistentProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getProjectRelativePath() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IPath getRawLocation() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public URI getRawLocationURI() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public ResourceAttributes getResourceAttributes() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getSessionProperty(QualifiedName key) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IWorkspace getWorkspace() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isAccessible() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLinked(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isLocal(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isPhantom() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isReadOnly() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isSynchronized(int depth) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isTeamPrivateMember() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, boolean force, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IPath destination, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void move(IProjectDescription description, boolean force, boolean keepHistory,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void revertModificationStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setDerived(boolean isDerived) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public long setLocalTimeStamp(long value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setReadOnly(boolean readOnly) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void touch(IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void create(IProjectDescription description, int updateFlags,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getPersistentProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Map getSessionProperties() throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isDerived(int options) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void setHidden(boolean isHidden) throws CoreException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="jar_example.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/common/tests/data/jar_example.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<javaElement handleIdentifier="=common/tests<jar.example"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
@@ -0,0 +1,340 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<resources>
|
||||
<!-- WARNING !!! THIS IS A MOCK FILE. DO NOT USE FOR DOCUMENTATION PURPOSES.
|
||||
This file has been trimmed down to only extract a number of interesting cases
|
||||
for unit tests.
|
||||
|
||||
What this contains:
|
||||
- View
|
||||
- ViewGroup
|
||||
- some attributes which format are defined in Theme
|
||||
- orientation, gravity and layout_gravity defined before they are used
|
||||
- ViewGroup_Layout
|
||||
- ViewGroup_MarginLayout
|
||||
- LinearLayout
|
||||
- LinearLayout_Layout
|
||||
- TableLayout
|
||||
|
||||
Note that TableLayout does not have a TableLayout_Layout definition here
|
||||
where these is a class TableLayout.LayoutData.
|
||||
-->
|
||||
|
||||
<!-- These are the standard attributes that make up a complete theme. -->
|
||||
<declare-styleable name="Theme">
|
||||
|
||||
<!-- Defines the scrollbars size. -->
|
||||
<attr name="scrollbarSize" format="dimension" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
|
||||
<!-- Standard orientation constant. -->
|
||||
<attr name="orientation">
|
||||
<!-- Defines an horizontal widget. -->
|
||||
<enum name="horizontal" value="0" />
|
||||
<!-- Defines a vertical widget. -->
|
||||
<enum name="vertical" value="1" />
|
||||
</attr>
|
||||
|
||||
<!-- Specifies how to place an object, both
|
||||
its x and y axis, within a larger containing object. -->
|
||||
<attr name="gravity">
|
||||
<!-- Push object to the top of its container, not changing its size. -->
|
||||
<flag name="top" value="0x30" />
|
||||
<!-- Push object to the bottom of its container, not changing its size. -->
|
||||
<flag name="bottom" value="0x50" />
|
||||
<!-- Push object to the left of its container, not changing its size. -->
|
||||
<flag name="left" value="0x03" />
|
||||
<!-- Push object to the right of its container, not changing its size. -->
|
||||
<flag name="right" value="0x05" />
|
||||
<!-- Place object in the vertical center of its container, not changing its size. -->
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<!-- Grow the vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<!-- Place object in the horizontal center of its container, not changing its size. -->
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
|
||||
<flag name="center" value="0x11" />
|
||||
<!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill" value="0x77" />
|
||||
</attr>
|
||||
|
||||
<!-- Standard gravity constant that a child can supply to its parent.
|
||||
Defines how to place an object, both
|
||||
its x and y axis, within a larger containing object. -->
|
||||
<attr name="layout_gravity">
|
||||
<!-- Push object to the top of its container, not changing its size. -->
|
||||
<flag name="top" value="0x30" />
|
||||
<!-- Push object to the bottom of its container, not changing its size. -->
|
||||
<flag name="bottom" value="0x50" />
|
||||
<!-- Push object to the left of its container, not changing its size. -->
|
||||
<flag name="left" value="0x03" />
|
||||
<!-- Push object to the right of its container, not changing its size. -->
|
||||
<flag name="right" value="0x05" />
|
||||
<!-- Place object in the vertical center of its container, not changing its size. -->
|
||||
<flag name="center_vertical" value="0x10" />
|
||||
<!-- Grow the vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_vertical" value="0x70" />
|
||||
<!-- Place object in the horizontal center of its container, not changing its size. -->
|
||||
<flag name="center_horizontal" value="0x01" />
|
||||
<!-- Grow the horizontal size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill_horizontal" value="0x07" />
|
||||
<!-- Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. -->
|
||||
<flag name="center" value="0x11" />
|
||||
<!-- Grow the horizontal and vertical size of the object if needed so it completely fills its container. -->
|
||||
<flag name="fill" value="0x77" />
|
||||
</attr>
|
||||
|
||||
<declare-styleable name="View">
|
||||
<!-- NOTE: View does not have a javadoc. Do not place a comment BEFORE View to make sure it
|
||||
is NOT interpreted as Javadoc -->
|
||||
|
||||
<!-- Supply an identifier name for this view, to later retrieve it
|
||||
with {@link android.view.View#findViewById View.findViewById()} or
|
||||
{@link android.app.Activity#findViewById Activity.findViewById()}.
|
||||
This must be a
|
||||
resource reference; typically you set this using the
|
||||
<code>@+</code> syntax to create a new ID resources.
|
||||
For example: <code>android:id="@+id/my_id"</code> which
|
||||
allows you to later retrieve the view
|
||||
with <code>findViewById(R.id.my_id)</code>. -->
|
||||
<attr name="id" format="reference" />
|
||||
|
||||
<!-- Supply a tag for this view containing a String, to be retrieved
|
||||
later with {@link android.view.View#getTag View.getTag()} or
|
||||
searched for with {@link android.view.View#findViewWithTag
|
||||
View.findViewWithTag()}. It is generally preferable to use
|
||||
IDs (through the android:id attribute) instead of tags because
|
||||
they are faster and allow for compile-time type checking. -->
|
||||
<attr name="tag" format="string" />
|
||||
|
||||
<!-- The initial horizontal scroll offset, in pixels.-->
|
||||
<attr name="scrollX" format="dimension" />
|
||||
|
||||
<!-- The initial vertical scroll offset, in pixels. -->
|
||||
<attr name="scrollY" format="dimension" />
|
||||
|
||||
<!-- A drawable to use as the background. This can be either a reference
|
||||
to a full drawable resource (such as a PNG image, 9-patch,
|
||||
XML state list description, etc), or a solid color such as "#ff000000"
|
||||
(black). -->
|
||||
<attr name="background" format="reference|color" />
|
||||
|
||||
<!-- Boolean that controls whether a view can take focus. By default the user can not
|
||||
move focus to a view; by setting this attribute to true the view is
|
||||
allowed to take focus. This value does not impact the behavior of
|
||||
directly calling {@link android.view.View#requestFocus}, which will
|
||||
always request focus regardless of this view. It only impacts where
|
||||
focus navigation will try to move focus. -->
|
||||
<attr name="focusable" format="boolean" />
|
||||
|
||||
<!-- Sets the circumstances under which this view will take focus. There are
|
||||
two choices: "weak" or "normal". The default value is "normal" for
|
||||
any focusable views. The focus type only applies if the view
|
||||
has been set to be focusable. -->
|
||||
<attr name="focusType">
|
||||
<!-- This view is focusable, but only if none of its descendants are already focused. -->
|
||||
<enum name="normal" value="0" />
|
||||
<!-- This view will always claim to be focusable. -->
|
||||
<enum name="weak" value="1" />
|
||||
</attr>
|
||||
|
||||
<!-- Controls the initial visibility of the view. -->
|
||||
<attr name="visibility">
|
||||
<!-- Visible on screen; the default value. -->
|
||||
<enum name="visible" value="0" />
|
||||
<!-- Not displayed, but taken into account during layout (space is left for it). -->
|
||||
<enum name="invisible" value="1" />
|
||||
<!-- Completely hidden, as if the view had not been added. -->
|
||||
<enum name="gone" value="2" />
|
||||
</attr>
|
||||
|
||||
<!-- Defines which scrollbars should be displayed on scrolling or not. -->
|
||||
<attr name="scrollbars">
|
||||
<!-- No scrollbar is displayed. -->
|
||||
<flag name="none" value="0x00000000" />
|
||||
<!-- Displays horizontal scrollbar only. -->
|
||||
<flag name="horizontal" value="0x00000100" />
|
||||
<!-- Displays vertical scrollbar only. -->
|
||||
<flag name="vertical" value="0x00000200" />
|
||||
</attr>
|
||||
|
||||
<!-- Sets the width of vertical scrollbars and height of horizontal scrollbars. -->
|
||||
<attr name="scrollbarSize" />
|
||||
|
||||
<!-- Text to display. (copied from TextView for the extra localization) -->
|
||||
<attr name="text" format="string" localization="suggested" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Attributes that can be used with a {@link android.view.ViewGroup} or any
|
||||
of its subclasses. Also see {@link #ViewGroup_Layout} for
|
||||
attributes that this class processes in its children. -->
|
||||
<declare-styleable name="ViewGroup">
|
||||
<!-- Defines whether a child is limited to draw inside of its bounds or not.
|
||||
This is useful with animations that scale the size of the children to more
|
||||
than 100% for instance. In such a case, this property should be set to false
|
||||
to allow the children to draw outside of their bounds. The default value of
|
||||
this property is true. -->
|
||||
<attr name="clipChildren" format="boolean" />
|
||||
<!-- Defines the layout animation to use the first time the ViewGroup is laid out.
|
||||
Layout animations can also be started manually after the first layout. -->
|
||||
<attr name="layoutAnimation" format="reference" />
|
||||
<!-- Defines whether a child's animation should be kept when it is over. Keeping
|
||||
the animations is useful with animation whose final state is different from
|
||||
the initial state of the View. This is particularly useful with animation
|
||||
whose fillAfter property is enabled. This property is set to false by default. -->
|
||||
<attr name="persistentDrawingCache">
|
||||
<!-- The drawing cache is not persisted after use. -->
|
||||
<flag name="none" value="0x0" />
|
||||
<!-- The drawing cache is persisted after a layout animation. -->
|
||||
<flag name="animation" value="0x1" />
|
||||
<!-- The drawing cache is persisted after a scroll. -->
|
||||
<flag name="scrolling" value="0x2" />
|
||||
<!-- The drawing cache is always persisted. -->
|
||||
<flag name="all" value="0x3" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is the basic set of layout attributes that are common to all
|
||||
layout managers. These attributes are specified with the rest of
|
||||
a view's normal attributes (such as {@link android.R.attr#background},
|
||||
but will be parsed by the view's parent and ignored by the child.
|
||||
<p>The values defined here correspond to the base layout attribute
|
||||
class {@link android.view.ViewGroup.LayoutParams}. -->
|
||||
<declare-styleable name="ViewGroup_Layout">
|
||||
<!-- Specifies the basic width of the view. This is a required attribute
|
||||
for any view inside of a containing layout manager. Its value may
|
||||
be a dimension (such as "12dip") for a constant width or one of
|
||||
the special constants. -->
|
||||
<attr name="layout_width" format="dimension">
|
||||
<!-- The view should be as big as its parent (minus padding). -->
|
||||
<enum name="fill_parent" value="-1" />
|
||||
<!-- The view should be only big enough to enclose its content (plus padding). -->
|
||||
<enum name="wrap_content" value="-2" />
|
||||
</attr>
|
||||
|
||||
<!-- Specifies the basic height of the view. This is a required attribute
|
||||
for any view inside of a containing layout manager. Its value may
|
||||
be a dimension (such as "12dip") for a constant height or one of
|
||||
the special constants. -->
|
||||
<attr name="layout_height" format="dimension">
|
||||
<!-- The view should be as big as its parent (minus padding). -->
|
||||
<enum name="fill_parent" value="-1" />
|
||||
<!-- The view should be only big enough to enclose its content (plus padding). -->
|
||||
<enum name="wrap_content" value="-2" />
|
||||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is the basic set of layout attributes for layout managers that
|
||||
wish to place margins around their child views.
|
||||
These attributes are specified with the rest of
|
||||
a view's normal attributes (such as {@link android.R.attr#background},
|
||||
but will be parsed by the view's parent and ignored by the child.
|
||||
<p>The values defined here correspond to the base layout attribute
|
||||
class {@link android.view.ViewGroup.MarginLayoutParams}. -->
|
||||
<declare-styleable name="ViewGroup_MarginLayout">
|
||||
<attr name="layout_width" />
|
||||
<attr name="layout_height" />
|
||||
<!-- Specifies extra space on the left side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginLeft" format="dimension" />
|
||||
<!-- Specifies extra space on the top side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginTop" format="dimension" />
|
||||
<!-- Specifies extra space on the right side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginRight" format="dimension" />
|
||||
<!-- Specifies extra space on the bottom side of this view.
|
||||
This space is outside this view's bounds. -->
|
||||
<attr name="layout_marginBottom" format="dimension" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- This is a linear layout. -->
|
||||
<declare-styleable name="LinearLayout">
|
||||
<!-- Should the layout be a column or a row? Use "horizontal"
|
||||
for a row, "vertical" for a column. The default is
|
||||
horizontal. -->
|
||||
<attr name="orientation" />
|
||||
<attr name="baselineAligned" format="boolean|reference" />
|
||||
<!-- When a linear layout is part of another layout that is baseline
|
||||
aligned, it can specify which of its children to baseline align to
|
||||
(i.e which child TextView).-->
|
||||
<attr name="baselineAlignedChildIndex" format="integer|color" min="0"/>
|
||||
<!-- Defines the maximum weight sum. If unspecified, the sum is computed
|
||||
by adding the layout_weight of all of the children. This can be
|
||||
used for instance to give a single child 50% of the total available
|
||||
space by giving it a layout_weight of 0.5 and setting the weightSum
|
||||
to 1.0. -->
|
||||
<attr name="weightSum" format="float" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="LinearLayout_Layout">
|
||||
<attr name="layout_width" />
|
||||
<attr name="layout_height" />
|
||||
<attr name="layout_weight" format="float" />
|
||||
<attr name="layout_gravity" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="TableLayout">
|
||||
<!-- The 0 based index of the columns to stretch. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. You can stretch all columns by using the
|
||||
value "*" instead. Note that a column can be marked stretchable
|
||||
and shrinkable at the same time. -->
|
||||
<attr name="stretchColumns" format="string" />
|
||||
<!-- The 0 based index of the columns to shrink. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. You can shrink all columns by using the
|
||||
value "*" instead. Note that a column can be marked stretchable
|
||||
and shrinkable at the same time. -->
|
||||
<attr name="shrinkColumns" format="string" />
|
||||
<!-- The 0 based index of the columns to collapse. The column indices
|
||||
must be separated by a comma: 1, 2, 5. Illegal and duplicate
|
||||
indices are ignored. -->
|
||||
<attr name="collapseColumns" format="string" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Test for deprecated attributes. -->
|
||||
<declare-styleable name="DeprecatedTest">
|
||||
<!-- Deprecated comments using delimiters.
|
||||
Ignored. {@deprecated In-line deprecated.} {@ignore Ignored}.
|
||||
-->
|
||||
<attr name="deprecated-inline" />
|
||||
|
||||
<!-- Deprecated comments on their own line.
|
||||
@deprecated Multi-line version of deprecated
|
||||
that works till the next tag.
|
||||
@ignore This tag must be ignored
|
||||
-->
|
||||
<attr name="deprecated-multiline" />
|
||||
|
||||
<!-- This attribute is not deprecated. -->
|
||||
<attr name="deprecated-not" />
|
||||
|
||||
<!-- {@deprecated There is no other javadoc here. } -->
|
||||
<attr name="deprecated-no-javadoc" format="boolean" />
|
||||
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package mock_android.view;
|
||||
|
||||
public class View {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package mock_android.view;
|
||||
|
||||
public class ViewGroup extends View {
|
||||
|
||||
public class MarginLayoutParams extends LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
public class LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package mock_android.widget;
|
||||
|
||||
import mock_android.view.ViewGroup;
|
||||
|
||||
public class LinearLayout extends ViewGroup {
|
||||
|
||||
public class LayoutParams extends mock_android.view.ViewGroup.LayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package mock_android.widget;
|
||||
|
||||
import mock_android.view.ViewGroup;
|
||||
|
||||
public class TableLayout extends ViewGroup {
|
||||
|
||||
public class LayoutParams extends MarginLayoutParams {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user