Move out all framework-tests classes.

Previously tests/framework-tests contained a quarantined set of test classes
that needed access to package-private framework api. Running these tests
normally would cause the dalvik verifier to throw errors.

runtest now has support for turning off the dalvik verifier for frameworks
tests, so move this tests into their recommended location, close to the source
being tested.

Also move policy source into a 'src' folder to accommodate the tests move.

Change-Id: I62f839da185a55bc553b653bf583fd99da438512
diff --git a/tests/framework-tests/src/android/text/PackedIntVectorTest.java b/core/tests/coretests/src/android/text/PackedIntVectorTest.java
similarity index 98%
rename from tests/framework-tests/src/android/text/PackedIntVectorTest.java
rename to core/tests/coretests/src/android/text/PackedIntVectorTest.java
index 78cdee9..1dc683e 100644
--- a/tests/framework-tests/src/android/text/PackedIntVectorTest.java
+++ b/core/tests/coretests/src/android/text/PackedIntVectorTest.java
@@ -16,7 +16,6 @@
 
 package android.text;
 
-import android.text.PackedIntVector;
 import junit.framework.TestCase;
 
 /**
diff --git a/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java b/core/tests/coretests/src/com/android/internal/http/multipart/MultipartTest.java
similarity index 100%
rename from tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
rename to core/tests/coretests/src/com/android/internal/http/multipart/MultipartTest.java
diff --git a/tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java b/core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java
similarity index 100%
rename from tests/framework-tests/src/com/android/internal/os/LoggingPrintStreamTest.java
rename to core/tests/coretests/src/com/android/internal/os/LoggingPrintStreamTest.java
diff --git a/policy/Android.mk b/policy/Android.mk
index a887142..47d8fb8 100644
--- a/policy/Android.mk
+++ b/policy/Android.mk
@@ -4,9 +4,11 @@
 # ============================================================
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := \
-            $(call all-subdir-java-files)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
             
 LOCAL_MODULE := android.policy
 
 include $(BUILD_JAVA_LIBRARY)
+
+# additionally, build unit tests in a separate .apk
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/policy/com/android/internal/policy/impl/AccountUnlockScreen.java b/policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/AccountUnlockScreen.java
rename to policy/src/com/android/internal/policy/impl/AccountUnlockScreen.java
diff --git a/policy/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/GlobalActions.java
rename to policy/src/com/android/internal/policy/impl/GlobalActions.java
diff --git a/policy/com/android/internal/policy/impl/IconUtilities.java b/policy/src/com/android/internal/policy/impl/IconUtilities.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/IconUtilities.java
rename to policy/src/com/android/internal/policy/impl/IconUtilities.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardScreen.java b/policy/src/com/android/internal/policy/impl/KeyguardScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardScreen.java
rename to policy/src/com/android/internal/policy/impl/KeyguardScreen.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardScreenCallback.java b/policy/src/com/android/internal/policy/impl/KeyguardScreenCallback.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardScreenCallback.java
rename to policy/src/com/android/internal/policy/impl/KeyguardScreenCallback.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
rename to policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardViewBase.java b/policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardViewBase.java
rename to policy/src/com/android/internal/policy/impl/KeyguardViewBase.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardViewCallback.java b/policy/src/com/android/internal/policy/impl/KeyguardViewCallback.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardViewCallback.java
rename to policy/src/com/android/internal/policy/impl/KeyguardViewCallback.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardViewManager.java
rename to policy/src/com/android/internal/policy/impl/KeyguardViewManager.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardViewMediator.java
rename to policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardViewProperties.java b/policy/src/com/android/internal/policy/impl/KeyguardViewProperties.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardViewProperties.java
rename to policy/src/com/android/internal/policy/impl/KeyguardViewProperties.java
diff --git a/policy/com/android/internal/policy/impl/KeyguardWindowController.java b/policy/src/com/android/internal/policy/impl/KeyguardWindowController.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/KeyguardWindowController.java
rename to policy/src/com/android/internal/policy/impl/KeyguardWindowController.java
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/LockPatternKeyguardView.java
rename to policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
diff --git a/policy/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
rename to policy/src/com/android/internal/policy/impl/LockPatternKeyguardViewProperties.java
diff --git a/policy/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/LockScreen.java
rename to policy/src/com/android/internal/policy/impl/LockScreen.java
diff --git a/policy/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PasswordUnlockScreen.java
rename to policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
diff --git a/policy/com/android/internal/policy/impl/PatternUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PatternUnlockScreen.java
rename to policy/src/com/android/internal/policy/impl/PatternUnlockScreen.java
diff --git a/policy/com/android/internal/policy/impl/PhoneLayoutInflater.java b/policy/src/com/android/internal/policy/impl/PhoneLayoutInflater.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PhoneLayoutInflater.java
rename to policy/src/com/android/internal/policy/impl/PhoneLayoutInflater.java
diff --git a/policy/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PhoneWindow.java
rename to policy/src/com/android/internal/policy/impl/PhoneWindow.java
diff --git a/policy/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PhoneWindowManager.java
rename to policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
diff --git a/policy/com/android/internal/policy/impl/Policy.java b/policy/src/com/android/internal/policy/impl/Policy.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/Policy.java
rename to policy/src/com/android/internal/policy/impl/Policy.java
diff --git a/policy/com/android/internal/policy/impl/PowerDialog.java b/policy/src/com/android/internal/policy/impl/PowerDialog.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/PowerDialog.java
rename to policy/src/com/android/internal/policy/impl/PowerDialog.java
diff --git a/policy/com/android/internal/policy/impl/RecentApplicationsBackground.java b/policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/RecentApplicationsBackground.java
rename to policy/src/com/android/internal/policy/impl/RecentApplicationsBackground.java
diff --git a/policy/com/android/internal/policy/impl/RecentApplicationsDialog.java b/policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/RecentApplicationsDialog.java
rename to policy/src/com/android/internal/policy/impl/RecentApplicationsDialog.java
diff --git a/policy/com/android/internal/policy/impl/ShortcutManager.java b/policy/src/com/android/internal/policy/impl/ShortcutManager.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/ShortcutManager.java
rename to policy/src/com/android/internal/policy/impl/ShortcutManager.java
diff --git a/policy/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
similarity index 100%
rename from policy/com/android/internal/policy/impl/SimUnlockScreen.java
rename to policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
diff --git a/policy/com/android/internal/policy/impl/package.html b/policy/src/com/android/internal/policy/impl/package.html
similarity index 100%
rename from policy/com/android/internal/policy/impl/package.html
rename to policy/src/com/android/internal/policy/impl/package.html
diff --git a/policy/tests/Android.mk b/policy/tests/Android.mk
new file mode 100644
index 0000000..ffb60b1
--- /dev/null
+++ b/policy/tests/Android.mk
@@ -0,0 +1,29 @@
+# Copyright 2010, 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.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+# We only want this apk build for tests.
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_JAVA_LIBRARIES := android.policy android.test.runner
+
+# Include all test java files.
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := FrameworkPolicyTests
+
+include $(BUILD_PACKAGE)
+
diff --git a/policy/tests/AndroidManifest.xml b/policy/tests/AndroidManifest.xml
new file mode 100644
index 0000000..dbdabfa
--- /dev/null
+++ b/policy/tests/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="com.android.frameworks.policy.tests">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    
+    <instrumentation
+        android:name="android.test.InstrumentationTestRunner"
+        android:targetPackage="com.android.frameworks.policy.tests"
+        android:label="Framework policy tests" />
+</manifest>
diff --git a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java b/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
similarity index 97%
rename from tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
rename to policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
index 1e57bd2..bdfe652 100644
--- a/tests/framework-tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
+++ b/policy/tests/src/com/android/internal/policy/impl/LockPatternKeyguardViewTest.java
@@ -55,8 +55,8 @@
         boolean isLockPatternEnabled = true;
         public boolean isPermanentlyLocked = false;
 
-        public MockLockPatternUtils() {
-            super(null);
+        public MockLockPatternUtils(Context context) {
+            super(context);
         }
 
         @Override
@@ -149,7 +149,7 @@
         @Override
         View createUnlockScreenFor(UnlockMode unlockMode) {
             final MockKeyguardScreen newView = new MockKeyguardScreen(getContext());
-            if (mInjectedUnlockScreens == null)  mInjectedUnlockScreens = Lists.newArrayList();
+            if (mInjectedUnlockScreens == null) mInjectedUnlockScreens = Lists.newArrayList();
             mInjectedUnlockScreens.add(newView);
             return newView;
         }
@@ -197,7 +197,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         mUpdateMonitor = new MockUpdateMonitor(getContext());
-        mLockPatternUtils = new MockLockPatternUtils();
+        mLockPatternUtils = new MockLockPatternUtils(getContext());
 
         mLPKV = new TestableLockPatternKeyguardView(getContext(), mUpdateMonitor,
                 mLockPatternUtils, new KeyguardWindowController() {
diff --git a/tests/framework-tests/Android.mk b/tests/framework-tests/Android.mk
deleted file mode 100644
index 5053e7d..0000000
--- a/tests/framework-tests/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/tests/framework-tests/README b/tests/framework-tests/README
deleted file mode 100644
index 7b46b25..0000000
--- a/tests/framework-tests/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This package contains tests which need to access package-private members in the framework code.
-To do this, the tests must be loaded in the same class loader as the classes which they are
-testing. This package is loaded in the boot classpath.
-
-Run these tests via AndroidTests -> FrameworkTests.
diff --git a/tests/framework-tests/src/Android.mk b/tests/framework-tests/src/Android.mk
deleted file mode 100644
index f537b52..0000000
--- a/tests/framework-tests/src/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_MODULE := framework-tests
-
-LOCAL_JAVA_LIBRARIES := android.policy android.test.runner
-
-include $(BUILD_JAVA_LIBRARY)
diff --git a/tests/framework-tests/src/android/test/FrameworkTests.java b/tests/framework-tests/src/android/test/FrameworkTests.java
deleted file mode 100644
index cb3f493..0000000
--- a/tests/framework-tests/src/android/test/FrameworkTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2007 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.
- */
-
-package android.test;
-
-import com.android.internal.os.LoggingPrintStreamTest;
-import junit.framework.TestSuite;
-import com.android.internal.http.multipart.MultipartTest;
-import com.android.internal.policy.impl.LockPatternKeyguardViewTest;
-
-/**
- * Tests that are loaded in the boot classpath along with the Android framework
- * classes. This enables you to access package-private members in the framework
- * classes; doing so is not possible when the test classes are loaded in an
- * application classloader.
- */
-public class FrameworkTests {
-    public static TestSuite suite() {
-        TestSuite suite = new TestSuite(FrameworkTests.class.getName());
-
-        suite.addTestSuite(MultipartTest.class);
-        suite.addTestSuite(LoggingPrintStreamTest.class);
-        suite.addTestSuite(LockPatternKeyguardViewTest.class);
-
-        return suite;
-    }
-}