package com.novoda.imageloader.acceptance;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.AbsListView;

import com.jayway.android.robotium.solo.Solo;
import com.novoda.imageloader.demo.activity.ImageLongList;
import com.novoda.imageloader.demo.R;

public class ImageLoaderDemoActivityTest extends ActivityInstrumentationTestCase2<ImageLongList> {
    private Solo solo;

    public ImageLoaderDemoActivityTest() {
        super("com.novoda.imageloader.demo", ImageLongList.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        solo = new Solo(getInstrumentation(), getActivity());
    }

    public void testOpenTheActivity() {
        assertNotNull(solo);
    }

    public void testScrollingDownTheList() {
        AbsListView list = (AbsListView) solo.getView(R.id.list_view);
        solo.scrollListToTop(list);
        
        boolean shouldScroll = true;
        while (shouldScroll) {
            shouldScroll = solo.scrollDownList(list);
        }
        
        assertEquals(list.getLastVisiblePosition(), list.getSelectedItemPosition());
    }
}


@@ -91,16 +91,41 @@
 tCase2;%0A
+import android.util.Log;%0A
 import a
@@ -237,30 +237,9 @@
 emo.
-activity.ImageLongList
+R
 ;%0Aim
@@ -271,17 +271,38 @@
 er.demo.
-R
+activity.ImageLongList
 ;%0A%0Apubli
@@ -797,16 +797,22 @@
 gDownThe
+Entire
 List() %7B
@@ -919,24 +919,16 @@
 (list);%0A
-        
 %0A       
@@ -1052,24 +1052,25 @@
       %7D%0A
+%0A
         
 %0A       
@@ -1061,16 +1061,344 @@
         
+int lastVisiblePosition = list.getLastVisiblePosition();%0A        int selectedPosition = list.getSelectedItemPosition();%0A%0A        Log.d(%22IMAGELOADER%22, %22adapter count: %22 + list.getAdapter().getCount());%0A        Log.d(%22IMAGELOADER%22, %22lastVis: %22 + lastVisiblePosition);%0A        Log.d(%22IMAGELOADER%22, %22selected: %22 + selectedPosition);
 %0A       

add logging