// Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
// 
//     public InvalidSelectorException(String message) {
//         super(message);
//     }
// 
//     public InvalidSelectorException(String message, Exception cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
// 
//     private final List<List<Selector>> selectorGroups;
// 
//     public ViewSelector(List<List<Selector>> selectorGroups) {
//         this.selectorGroups = selectorGroups;
//     }
// 
//     /**
//      * Applies this selector to the given view, selecting all descendants of the
//      * view that match this selector.
//      * @return the ordered set of views that matches this selector
//      */
//     public ViewSelection selectViews(View view) {
//         ViewSelection result = new ViewSelection();
//         for (List<Selector> selectorParts : selectorGroups) {
//             result.addAll(selectViewsForGroup(selectorParts, view));
//         }
//         return result;
//     }
// 
//     private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
//         ViewSelection result = new ViewSelection();
//         result.add(view);
//         for (Selector selector : selectorParts) {
//             ViewTraversalChecker checker = new ClassChecker(selector, view);
//             result = checker.check(result);
//             if (result.isEmpty()) {
//                 return result;
//             }
// 
//             if (selector.hasSpecifiers())  {
//                 for (Specifier specifier : selector.getSpecifiers()) {
//                     switch (specifier.getType()) {
//                         case ATTRIBUTE:
//                             checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
//                             break;
//                         default:
//                             throw new UnsupportedOperationException();
//                     }
//                     result = checker.check(result);
//                     if (result.isEmpty()) {
//                         return result;
//                     }
//                 }
//             }
//         }
//         return result;
//     }
// 
//     /**
//      * @return a new ViewSelector from the given selector string
//      * @throws InvalidSelectorException if the given selector string can't be parsed into
//      *     a valid selector
//      */
//     public static ViewSelector compile(String selectorString) {
//         List<List<Selector>> groups;
//         try {
//             Scanner scanner = new Scanner(selectorString);
//             groups = scanner.scan();
//         } catch (ScannerException ex) {
//             throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
//         }
//         return new ViewSelector(groups);
//     }
// }
// 
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
// 
// }
// 
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
// 
//     protected ViewFactory viewFactory;
// 
//     @Before
//     public void setUp() throws Exception {
//         super.setUp();
//         viewFactory = createViewFactory();
//     }
// 
//     /**
//      * @return the factory to be used for creating views in this test
//      */
//     protected abstract ViewFactory createViewFactory();
// 
//     /**
//      * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
//      * can't use MoreAsserts in Robolectric 1.2.
//      */
//     public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
//         ArrayList<Object> actualList = new ArrayList<Object>();
//         for (Object o : actual) {
//             actualList.add(o);
//         }
//         assertEquals(Arrays.asList(expected), actualList);
//     }
// }


import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;
package com.nikhaldimann.viewselector.test.abstrakt;




public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {

    private ViewSelection selectViews(String selector, View view) {
        return ViewSelector.compile(selector).selectViews(view);
    }

    @Test
    public void testSelectViewsSimpleSingleView() {
        TextView view = viewFactory.createTextView();
        assertContentsInOrder(selectViews("EditView", view));
        assertContentsInOrder(selectViews("TextView", view), view);
        assertContentsInOrder(selectViews("", view));
        assertContentsInOrder(selectViews("  ", view));
    }

    @Test
    public void testCompileInvalidSelector() {
        try {
            ViewSelector.compile("> EditView");
            fail();
// Path: src/main/java/com/nikhaldimann/viewselector/InvalidSelectorException.java
// public class InvalidSelectorException extends RuntimeException {
// 
//     public InvalidSelectorException(String message) {
//         super(message);
//     }
// 
//     public InvalidSelectorException(String message, Exception cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/com/nikhaldimann/viewselector/ViewSelector.java
// public class ViewSelector {
// 
//     private final List<List<Selector>> selectorGroups;
// 
//     public ViewSelector(List<List<Selector>> selectorGroups) {
//         this.selectorGroups = selectorGroups;
//     }
// 
//     /**
//      * Applies this selector to the given view, selecting all descendants of the
//      * view that match this selector.
//      * @return the ordered set of views that matches this selector
//      */
//     public ViewSelection selectViews(View view) {
//         ViewSelection result = new ViewSelection();
//         for (List<Selector> selectorParts : selectorGroups) {
//             result.addAll(selectViewsForGroup(selectorParts, view));
//         }
//         return result;
//     }
// 
//     private ViewSelection selectViewsForGroup(List<Selector> selectorParts, View view) {
//         ViewSelection result = new ViewSelection();
//         result.add(view);
//         for (Selector selector : selectorParts) {
//             ViewTraversalChecker checker = new ClassChecker(selector, view);
//             result = checker.check(result);
//             if (result.isEmpty()) {
//                 return result;
//             }
// 
//             if (selector.hasSpecifiers())  {
//                 for (Specifier specifier : selector.getSpecifiers()) {
//                     switch (specifier.getType()) {
//                         case ATTRIBUTE:
//                             checker = new AttributeSpecifierChecker((AttributeSpecifier) specifier, view);
//                             break;
//                         default:
//                             throw new UnsupportedOperationException();
//                     }
//                     result = checker.check(result);
//                     if (result.isEmpty()) {
//                         return result;
//                     }
//                 }
//             }
//         }
//         return result;
//     }
// 
//     /**
//      * @return a new ViewSelector from the given selector string
//      * @throws InvalidSelectorException if the given selector string can't be parsed into
//      *     a valid selector
//      */
//     public static ViewSelector compile(String selectorString) {
//         List<List<Selector>> groups;
//         try {
//             Scanner scanner = new Scanner(selectorString);
//             groups = scanner.scan();
//         } catch (ScannerException ex) {
//             throw new InvalidSelectorException("Invalid selector: " + selectorString, ex);
//         }
//         return new ViewSelector(groups);
//     }
// }
// 
// Path: src/main/java/com/nikhaldimann/viewselector/selection/ViewSelection.java
// public class ViewSelection extends LinkedHashSet<View> {
// 
// }
// 
// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/util/ViewSelectorAndroidTestCase.java
// public abstract class ViewSelectorAndroidTestCase extends AndroidTestCase {
// 
//     protected ViewFactory viewFactory;
// 
//     @Before
//     public void setUp() throws Exception {
//         super.setUp();
//         viewFactory = createViewFactory();
//     }
// 
//     /**
//      * @return the factory to be used for creating views in this test
//      */
//     protected abstract ViewFactory createViewFactory();
// 
//     /**
//      * Reimplementation of Android's MoreAsserts.assertContentsInOrder() because we
//      * can't use MoreAsserts in Robolectric 1.2.
//      */
//     public static void assertContentsInOrder(Iterable<?> actual, Object... expected) {
//         ArrayList<Object> actualList = new ArrayList<Object>();
//         for (Object o : actual) {
//             actualList.add(o);
//         }
//         assertEquals(Arrays.asList(expected), actualList);
//     }
// }


// Path: src/test-lib/src/com/nikhaldimann/viewselector/test/abstrakt/AbstractViewSelectorTest.java
import org.junit.Test;
import android.text.InputType;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.nikhaldimann.viewselector.InvalidSelectorException;
import com.nikhaldimann.viewselector.ViewSelector;
import com.nikhaldimann.viewselector.selection.ViewSelection;
import com.nikhaldimann.viewselector.test.R;
import com.nikhaldimann.viewselector.test.util.ViewSelectorAndroidTestCase;

package com.nikhaldimann.viewselector.test.abstrakt;




public abstract class AbstractViewSelectorTest extends ViewSelectorAndroidTestCase {

    private ViewSelection selectViews(String selector, View view) {
        return ViewSelector.compile(selector).selectViews(view);
    }

    @Test
    public void testSelectViewsSimpleSingleView() {
        TextView view = viewFactory.createTextView();
        assertContentsInOrder(selectViews("EditView", view));
        assertContentsInOrder(selectViews("TextView", view), view);
        assertContentsInOrder(selectViews("", view));
        assertContentsInOrder(selectViews("  ", view));
    }

    @Test
    public void testCompileInvalidSelector() {
        try {
            ViewSelector.compile("> EditView");
            fail();
        } catch (InvalidSelectorException ex) {