am c74e235e: am c16aefa1: am f6bf3177: Merge "Adds CtsVerifier sample tests." into klp-dev

* commit 'c74e235e0e1be734b22d27b5dc1696aa7836fb60':
  Adds CtsVerifier sample tests.
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index cf331eb..848c853 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -805,6 +805,15 @@
             </intent-filter>
         </activity-alias>
 
+        <activity android:name=".sample.SampleTestActivity"
+                  android:label="@string/sample_framework_test">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_other" />
+        </activity>
+
         <activity android:name=".widget.WidgetTestActivity"
                 android:label="@string/widget_framework_test">
             <intent-filter>
diff --git a/apps/CtsVerifier/res/layout/pass_fail_sample.xml b/apps/CtsVerifier/res/layout/pass_fail_sample.xml
new file mode 100644
index 0000000..84d79ee
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/pass_fail_sample.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+    <Button android:id="@+id/sample_share_btn"
+            android:text="@string/share_button_text"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+    <include android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            layout="@layout/pass_fail_buttons" />
+</RelativeLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 58f0103..e0e6dfc 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -412,6 +412,12 @@
     <!-- Magnetic Field -->
     <string name="snsr_mag_m_test">Magnetic Field Measurement Tests</string>
 
+    <!-- Strings for Sample Test Activities -->
+    <string name="share_button_text">Share</string>
+    <string name="sample_framework_test">Sample Framework Test</string>
+    <string name="sample_test">Sample Test</string>
+    <string name="sample_test_info">This test verifies that bluetooth sharing is working properly.\nThe test assumes the Device Under Test has bluetooth enabled and is already paired with a second device, also with bluetooth enabled.\nStart this test by clicking share, choose bluetooth from the options, and then select a device to share with.\nNote: This is a sample test, used to demonstrate how to write CTS Verifier tests, so just click pass.</string>
+
     <!-- Strings for SuidFilesActivity -->
     <string name="suid_files">SUID File Scanner</string>
     <string name="suid_files_info">This test will attempt to find unauthorized SUID binaries, but it is not comprehensive due to permission restrictions.\n\nAuthorized SUID binaries will appear green, while unauthorized SUID binaries will appear red.\n\nPress OK to start the scan...</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java
new file mode 100644
index 0000000..25f90d9
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2014 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 com.android.cts.verifier.sample;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+/**
+ * A sample CTS Verifier test case for testing file transfers using bluetooth sharing.
+ *
+ * This test assumes bluetooth is turned on and the device is already paired with a second device.
+ * Note: the second device need not be an Android device; it could be a laptop or desktop.
+ */
+public class SampleTestActivity extends PassFailButtons.Activity {
+
+    /**
+     * The name of the test file being transferred.
+     */
+    private static final String FILE_NAME = "test.txt";
+
+    /**
+     * The content of the test file being transferred.
+     */
+    private static final String TEST_STRING = "Sample Test String";
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        // Setup the UI.
+        setContentView(R.layout.pass_fail_sample);
+        setPassFailButtonClickListeners();
+        setInfoResources(R.string.sample_test, R.string.sample_test_info, -1);
+        // Get the share button and attach the listener.
+        Button shareBtn = (Button) findViewById(R.id.sample_share_btn);
+        shareBtn.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                try {
+                    createFileAndShare();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+    }
+
+    /**
+     * Creates a temporary file containing the test string and then issues the intent to share it.
+     *
+     * @throws Exception
+     */
+    private void createFileAndShare() throws Exception {
+        // Use the external cache directory so the file will be deleted when the app is uninstalled
+        // and the file can be accessed by other apps, such as the sharing app.
+        File dir = getExternalCacheDir ();
+        // Create the file with the given name.
+        File file = new File(dir, FILE_NAME);
+        FileOutputStream outputStream = null;
+        try {
+            // Write the test string to the test file.
+            outputStream = new FileOutputStream(file);
+            outputStream.write(TEST_STRING.getBytes());
+
+            // Create the share intent.
+            Intent intent = new Intent();
+            intent.setAction(Intent.ACTION_SEND);
+            intent.setType("text/plain");
+            intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
+            startActivity(intent);
+        } finally {
+            // Clean up.
+            if (outputStream != null) {
+                outputStream.close();
+            }
+        }
+
+    }
+}