// 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;
    }

    @Test
    public void testSelectyById() {
        TextView view = viewFactory.createTextView();
        view.setId(R.id.hello_world);
        assertContentsInOrder(selectViews("#hello_world", view), view);
        assertContentsInOrder(selectViews("#foobar", view));
        assertContentsInOrder(selectViews("TextView#hello_world", view), view);
        assertContentsInOrder(selectViews("ImageView#hello_world", view));
        assertContentsInOrder(selectViews("TextView#foobar", view));
    }

    @Test
    public void testSelectViewsDescendants() {
        LinearLayout layout = viewFactory.createLinearLayout();
        TextView view = viewFactory.createTextView();
        TextView view2 = viewFactory.createTextView();
        layout.addView(view);
        layout.addView(view2);
        assertContentsInOrder(selectViews("*", layout), layout, view, view2);
        assertContentsInOrder(selectViews("* TextView", layout), view, view2);
        assertContentsInOrder(selectViews("* *", layout), layout, view, view2);
        assertContentsInOrder(selectViews("* * Foo", layout));
    }

    @Test
    public void testSelectViewsChildren() {
        LinearLayout layout = viewFactory.createLinearLayout();
        TextView view = viewFactory.createTextView();
// 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;

    }

    @Test
    public void testSelectyById() {
        TextView view = viewFactory.createTextView();
        view.setId(R.id.hello_world);
        assertContentsInOrder(selectViews("#hello_world", view), view);
        assertContentsInOrder(selectViews("#foobar", view));
        assertContentsInOrder(selectViews("TextView#hello_world", view), view);
        assertContentsInOrder(selectViews("ImageView#hello_world", view));
        assertContentsInOrder(selectViews("TextView#foobar", view));
    }

    @Test
    public void testSelectViewsDescendants() {
        LinearLayout layout = viewFactory.createLinearLayout();
        TextView view = viewFactory.createTextView();
        TextView view2 = viewFactory.createTextView();
        layout.addView(view);
        layout.addView(view2);
        assertContentsInOrder(selectViews("*", layout), layout, view, view2);
        assertContentsInOrder(selectViews("* TextView", layout), view, view2);
        assertContentsInOrder(selectViews("* *", layout), layout, view, view2);
        assertContentsInOrder(selectViews("* * Foo", layout));
    }

    @Test
    public void testSelectViewsChildren() {
        LinearLayout layout = viewFactory.createLinearLayout();
        TextView view = viewFactory.createTextView();
        TextView view2 = viewFactory.createTextView();