Fix GridViewTest#testSetHorizontalSpacing

The test creates a GridView with 20 columns and puts 3 elements into it.
It then sets the horizontal spacing to values like 0 and 5 and checks
that the spacing between the views are 0 and 5. However, the GridView is
distributing the elements on the wide screen, so the spacing isn't
correct. Thus, set the stretch mode to none to fix the issue. This isn't
a new behavior in GridView.

Change-Id: Id30d378021b8de9d6c1e87cf79d5e2b75467749a
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index ee9c7e2..eb9782c 100644
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -16,6 +16,14 @@
 
 package android.widget.cts;
 
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.ToBeFixed;
+
 import org.xmlpull.v1.XmlPullParser;
 
 import android.app.Activity;
@@ -44,14 +52,6 @@
 import android.widget.ListAdapter;
 import android.widget.AdapterView.OnItemClickListener;
 
-import com.android.cts.stub.R;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.ToBeFixed;
-
 /**
  * Test {@link GridView}.
  */
@@ -72,7 +72,6 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-
         mGridView = null;
         mActivity = getActivity();
         mInstrumentation = getInstrumentation();
@@ -310,6 +309,7 @@
     )
     public void testSetHorizontalSpacing() {
         mGridView = findGridViewById(R.id.gridview);
+        mGridView.setStretchMode(GridView.NO_STRETCH);
         // Number of columns should be big enough, otherwise the
         // horizontal spacing cannot be correctly verified.
         mGridView.setNumColumns(20);
@@ -531,7 +531,7 @@
             assertEquals(0, child.getLeft() - mGridView.getListPaddingLeft());
         }
     }
-    
+
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         notes = "Test {@link GridView#getNumColumns()}",
@@ -539,11 +539,11 @@
     )
     public void testGetNumColumns() {
         mGridView = new GridView(mActivity);
-        
+
         assertEquals(mGridView.getNumColumns(), GridView.AUTO_FIT);
-        
+
         mGridView = findGridViewById(R.id.gridview);
-        
+
         mActivity.runOnUiThread(new Runnable() {
             public void run() {
                 mGridView.setAdapter(new MockGridViewAdapter(10));
@@ -551,7 +551,7 @@
             }
         });
         mInstrumentation.waitForIdleSync();
-        
+
         assertEquals(mGridView.getNumColumns(), 10);
 
         mActivity.runOnUiThread(new Runnable() {
@@ -560,7 +560,7 @@
             }
         });
         mInstrumentation.waitForIdleSync();
-        
+
         assertEquals(mGridView.getNumColumns(), 1);
 
         mActivity.runOnUiThread(new Runnable() {
@@ -569,7 +569,7 @@
             }
         });
         mInstrumentation.waitForIdleSync();
-        
+
         //although setNumColumns(0) was called, the number of columns should be 1
         assertEquals(mGridView.getNumColumns(), 1);
     }