Java Code Examples for android.support.test.espresso.UiController

The following are top voted examples for showing how to use android.support.test.espresso.UiController. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: fullscreen-video-view   File: CustomChecks.java   View source code 7 votes vote down vote up
static ViewAction clickNoConstraints() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isEnabled(); // No constraints, isEnabled and isClickable are checked
        }

        @Override
        public String getDescription() {
            return "Click a view with no constraints.";
        }

        @Override
        public void perform(UiController uiController, View view) {
            view.performClick();
        }
    };
}
 
Example 2
Project: GitHub   File: PubkeyListActivityTest.java   View source code 6 votes vote down vote up
private ViewAction fillEntropy() {
	return new ViewAction() {
		@Override
		public Matcher<View> getConstraints() {
			return allOf(isDisplayed(), isAssignableFrom(EntropyView.class));
		}

		@Override
		public String getDescription() {
			return "Dismisses the 'Gathering entropy...' dialog";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			((EntropyView) view).notifyListeners();
		}
	};
}
 
Example 3
Project: android-PictureInPicture   File: MediaSessionPlaybackActivityTest.java   View source code 6 votes vote down vote up
private static ViewAction showControls() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(MovieView.class);
        }

        @Override
        public String getDescription() {
            return "Show controls of MovieView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ((MovieView) view).showControls();
            uiController.loopMainThreadUntilIdle();
        }
    };
}
 
Example 4
Project: android-PictureInPicture   File: MainActivityTest.java   View source code 6 votes vote down vote up
private static ViewAction showControls() {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(MovieView.class);
        }

        @Override
        public String getDescription() {
            return "Show controls of MovieView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            ((MovieView) view).showControls();
            uiController.loopMainThreadUntilIdle();
        }
    };
}
 
Example 5
Project: DiscogsBrowser   File: TestUtils.java   View source code 6 votes vote down vote up
/**
 * From: http://stackoverflow.com/questions/33505953/espresso-how-to-test-swiperefreshlayout/33516360#33516360
 * <p>
 * ViewPager will throw an error if not 90% of it is displayed. This reduces the restriction.
 *
 * @param action      Action to be done.
 * @param constraints Restrictions on the view.
 * @return Performs an action on the view.
 */
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints)
{
    return new ViewAction()
    {
        @Override
        public Matcher<View> getConstraints()
        {
            return constraints;
        }

        @Override
        public String getDescription()
        {
            return action.getDescription();
        }

        @Override
        public void perform(UiController uiController, View view)
        {
            action.perform(uiController, view);
        }
    };
}
 
Example 6
Project: fullscreen-video-view   File: CustomChecks.java   View source code 6 votes vote down vote up
static ViewAction setOrientation(final int orientation) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {
            return "Change orientation";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();
            changeOrientation(view, orientation);
        }
    };
}
 
Example 7
Project: fullscreen-video-view   File: CustomChecks.java   View source code 6 votes vote down vote up
@Override
public void perform(UiController uiController, View view) {
    uiController.loopMainThreadUntilIdle();
    int orientation = getActivityOrientation(view);
    boolean checkOrientation = false;
    switch (orientationType) {
        case PORTRAIT:
            checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT;
            break;

        case LANDSCAPE:
            checkOrientation = orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
                    || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE;
            break;
    }

    if (checkOrientation) {
        isOrientation[0] = true;
    }
}
 
Example 8
Project: mapbox-plugins-android   File: LocationLayerTest.java   View source code 6 votes vote down vote up
@Test
public void onMapChangeLocationLayerRedrawn() throws Exception {
  executeLocationLayerTest(new LocationLayerPluginAction.onPerformLocationLayerAction() {
    @Override
    public void onLocationLayerAction(LocationLayerPlugin locationLayerPlugin, MapboxMap mapboxMap,
                                      UiController uiController) {
      locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
      assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
      mapboxMap.setStyleUrl(Style.SATELLITE);
      uiController.loopMainThreadForAtLeast(500);
      assertEquals(locationLayerPlugin.getLocationLayerMode(), LocationLayerMode.TRACKING);
      assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
      assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER).getVisibility().getValue()
        .equals(Property.VISIBLE));
    }
  });
}
 
Example 9
Project: ChimpCheck   File: FingerGestures.java   View source code 6 votes vote down vote up
public static ViewAction swipeOnCoord(final float fromX, final float fromY, final float toX, final float toY) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isRoot();
        }

        @Override
        public String getDescription() {

            return "Swipe from" + fromX + ", " + fromY + " to " + toX + ", " + toY;
        }

        @Override
        public void perform(UiController uiController, final View view) {
            drag(fromX, fromY, toX, toY);
        }
    };
}
 
Example 10
Project: DOUSalaries   File: TestUtils.java   View source code 6 votes vote down vote up
public void perform(UiController uiController, View view) {
    RecyclerView recyclerView = (RecyclerView) view;
    (new ScrollToPositionViewAction(this.position)).perform(uiController, view);
    uiController.loopMainThreadUntilIdle();

    View targetView = recyclerView.getChildAt(this.position).findViewById(this.viewId);

    if (targetView == null) {
        throw (new PerformException.Builder()).withActionDescription(this.toString())
                .withViewDescription(HumanReadables.describe(view))
                .withCause(new IllegalStateException(
                        "No view with id "
                                + this.viewId
                                + " found at position: "
                                + this.position)
                )
                .build();
    }
    else {
        this.viewAction.perform(uiController, targetView);
    }
}
 
Example 11
Project: polling-station-app   File: TestMainActivity.java   View source code 6 votes vote down vote up
/**
 * Test if the manual input activity opens.
 */
@Test
public void testGoToManual() {
    onView(withId(R.id.manual_input_button)).check(matches(allOf( isEnabled(), isClickable()))).perform(
            new ViewAction() {
                @Override
                public Matcher<View> getConstraints() {
                    return isEnabled(); // no constraints, they are checked above
                }

                @Override
                public String getDescription() {
                    return "click manual input button";
                }

                @Override
                public void perform(UiController uiController, View view) {
                    view.performClick();
                }
            }
    );
    intended(hasComponent(ManualInputActivity.class.getName()));
}
 
Example 12
Project: orgzly-android   File: EspressoUtils.java   View source code 6 votes vote down vote up
/**
 * Set value for {@link NumberPicker}
 */
public static ViewAction setNumber(final int n) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            ((NumberPicker) view).setValue(n);
        }

        @Override
        public String getDescription() {
            return "Set NumberPicker value";
        }

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(NumberPicker.class);
        }
    };
}
 
Example 13
Project: EncryptAndroidSample   File: ExampleInstrumentedTest.java   View source code 6 votes vote down vote up
/**
 * Try to getText from TextView
 */
private String getText(final Matcher<View> matcher) {
    final String[] stringHolder = { null };
    onView(matcher).perform(new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return isAssignableFrom(TextView.class);
        }

        @Override
        public String getDescription() {
            return "getting text from a TextView";
        }

        @Override
        public void perform(UiController uiController, View view) {
            TextView tv = (TextView) view;
            stringHolder[0] = tv.getText().toString();
        }
    });
    return stringHolder[0];
}
 
Example 14
Project: Mixtape   File: RecyclerBodyViewViewActions.java   View source code 6 votes vote down vote up
public static ViewAction scrollToEnd() {
	return new ViewAction() {
		@Override
		public Matcher<View> getConstraints() {
			return isAssignableFrom(RecyclerBodyView.class);
		}

		@Override
		public String getDescription() {
			return "scroll to end";
		}

		@Override
		public void perform(final UiController uiController, final View view) {
			final RecyclerBodyView castView = (RecyclerBodyView) view;
			castView.showItem(castView.getItems().size() - 1);
		}
	};
}
 
Example 15
Project: firefox-tv   File: PullDownToRefreshTest.java   View source code 6 votes vote down vote up
public static ViewAction withCustomConstraints(final ViewAction action, final Matcher<View> constraints) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return constraints;
        }

        @Override
        public String getDescription() {
            return action.getDescription();
        }

        @Override
        public void perform(UiController uiController, View view) {
            action.perform(uiController, view);
        }
    };
}
 
Example 16
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineOffsetFunctionMotorwayBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(MotorWay.BASE_LAYER_ID);
      assertNotNull(layer.getLineOffset());
      assertNotNull(layer.getLineOffset().getFunction());
      assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001);
      assertEquals(5, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
    }
  });
}
 
Example 17
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinTrunkCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Trunk.CASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 18
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineOffsetFunctionMotorwayCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(MotorWay.CASE_LAYER_ID);
      assertNotNull(layer.getLineOffset());
      assertNotNull(layer.getLineOffset().getFunction());
      assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001);
      assertEquals(5, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
    }
  });
}
 
Example 19
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinTrunkBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Trunk.BASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 20
Project: mapbox-navigation-android   File: NavigationMapRouteTest.java   View source code 5 votes vote down vote up
@Test
public void routeLayerShieldVisible() throws Exception {
  executeNavigationMapRoute(new NavigationMapRouteAction.OnPerformNavigationMapRouteAction() {
    @Override
    public void onNavigationMapRouteAction(NavigationMapRoute navigationMapRoute, MapboxMap mapboxMap,
                                           UiController controller) {
      assertTrue(mapboxMap.getLayer(GENERIC_ROUTE_SHIELD_LAYER_ID)
        .getVisibility().getValue().equals(Property.VISIBLE));
    }
  });
}
 
Example 21
Project: mapbox-navigation-android   File: NavigationMapRouteTest.java   View source code 5 votes vote down vote up
@Test
public void routeLayerVisible() throws Exception {
  executeNavigationMapRoute(new NavigationMapRouteAction.OnPerformNavigationMapRouteAction() {
    @Override
    public void onNavigationMapRouteAction(NavigationMapRoute navigationMapRoute, MapboxMap mapboxMap,
                                           UiController controller) {
      assertTrue(mapboxMap.getLayer(GENERIC_ROUTE_LAYER_ID)
        .getVisibility().getValue().equals(Property.VISIBLE));
    }
  });
}
 
Example 22
Project: mapbox-navigation-android   File: NavigationMapRouteTest.java   View source code 5 votes vote down vote up
@Test
public void removeRouteHidesSheildLayer() throws Exception {
  executeNavigationMapRoute(new NavigationMapRouteAction.OnPerformNavigationMapRouteAction() {
    @Override
    public void onNavigationMapRouteAction(NavigationMapRoute navigationMapRoute, MapboxMap mapboxMap,
                                           UiController controller) {
      navigationMapRoute.removeRoute();
      assertTrue(mapboxMap.getLayer(GENERIC_ROUTE_SHIELD_LAYER_ID)
        .getVisibility().getValue().equals(Property.NONE));
    }
  });
}
 
Example 23
Project: mapbox-navigation-android   File: NavigationMapRouteTest.java   View source code 5 votes vote down vote up
@Test
public void removeRouteHidesLayer() throws Exception {
  executeNavigationMapRoute(new NavigationMapRouteAction.OnPerformNavigationMapRouteAction() {
    @Override
    public void onNavigationMapRouteAction(NavigationMapRoute navigationMapRoute, MapboxMap mapboxMap,
                                           UiController controller) {
      navigationMapRoute.removeRoute();
      assertTrue(mapboxMap.getLayer(GENERIC_ROUTE_LAYER_ID)
        .getVisibility().getValue().equals(Property.NONE));
    }
  });
}
 
Example 24
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinPrimaryBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Primary.BASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 25
Project: mapbox-navigation-android   File: NavigationMapRouteTest.java   View source code 5 votes vote down vote up
@Test
public void reattachRouteLayerWithLoadNewStyle() throws Exception {
  executeNavigationMapRoute(new NavigationMapRouteAction.OnPerformNavigationMapRouteAction() {
    @Override
    public void onNavigationMapRouteAction(NavigationMapRoute navigationMapRoute, MapboxMap mapboxMap,
                                           UiController controller) {
      mapboxMap.setStyleUrl(Style.DARK);
      controller.loopMainThreadForAtLeast(500);
      assertTrue(mapboxMap.getLayer(GENERIC_ROUTE_LAYER_ID) != null);
    }
  });
}
 
Example 26
Project: mapbox-plugins-android   File: LocationLayerTest.java   View source code 5 votes vote down vote up
@Test
public void locationSourceAdded() throws Exception {
  executeLocationLayerTest(new LocationLayerPluginAction.onPerformLocationLayerAction() {
    @Override
    public void onLocationLayerAction(LocationLayerPlugin locationLayerPlugin, MapboxMap mapboxMap,
                                      UiController uiController) {
      locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
      assertTrue(mapboxMap.getSource(LOCATION_SOURCE) != null);
    }
  });
}
 
Example 27
Project: TripleTap   File: MultiplayerGameFragmentAndroidTests.java   View source code 5 votes vote down vote up
@Override
public void perform(UiController uiController, View view) {
    view.performClick();
}
 
Example 28
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinSecondaryBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Secondary.BASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 29
Project: TripleTap   File: NormalGameFragmentAndroidTests.java   View source code 5 votes vote down vote up
@Override
public void perform(UiController uiController, View view) {
    view.performClick();
}
 
Example 30
Project: mapbox-navigation-android   File: WaitLoopAction.java   View source code 5 votes vote down vote up
public static void performWaitLoop(UiController controller, long waitTime) {
  controller.loopMainThreadForAtLeast(waitTime);
}
 
Example 31
Project: PXLSRT   File: CameraViewTest.java   View source code 5 votes vote down vote up
private static ViewAction waitFor(final long ms) {
    return new AnythingAction("wait") {
        @Override
        public void perform(UiController uiController, View view) {
            SystemClock.sleep(ms);
        }
    };
}
 
Example 32
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinPrimaryCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Primary.CASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 33
Project: FancyTrendView   File: OrientationChangeAction.java   View source code 5 votes vote down vote up
@Override
public void perform(UiController uiController, View view) {
    uiController.loopMainThreadUntilIdle();
    final Activity activity = (Activity) view.getContext();
    activity.setRequestedOrientation(orientation);

    Collection<Activity> resumedActivities = ActivityLifecycleMonitorRegistry.getInstance().getActivitiesInStage(Stage.RESUMED);
    if (resumedActivities.isEmpty()) {
        throw new RuntimeException("Could not change orientation");
    }
}
 
Example 34
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineOffsetFunctionPrimaryBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(Primary.BASE_LAYER_ID);
      assertNotNull(layer.getLineOffset());
      assertNotNull(layer.getLineOffset().getFunction());
      assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001);
      assertEquals(4, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
    }
  });
}
 
Example 35
Project: TurboChat   File: EspressoTestUtils.java   View source code 5 votes vote down vote up
public static ViewAction clickClickableSpan(final CharSequence textToClick) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return instanceOf(TextView.class);
        }

        @Override
        public String getDescription() {
            return "clicking on a ClickableSpan";
        }

        @Override
        public void perform(UiController uiController, View view) {
            TextView textView = (TextView) view;
            SpannableString spannableString = (SpannableString) textView.getText();

            if (spannableString.length() == 0) {
                // TextView is empty, nothing to do
                throw new NoMatchingViewException.Builder()
                        .includeViewHierarchy(true)
                        .withRootView(textView)
                        .build();
            }

            // Get the links inside the TextView and check if we find textToClick
            ClickableSpan[] spans = spannableString.getSpans(0, spannableString.length(), ClickableSpan.class);
            if (spans.length > 0) {
                ClickableSpan spanCandidate;
                for (ClickableSpan span : spans) {
                    spanCandidate = span;
                    int start = spannableString.getSpanStart(spanCandidate);
                    int end = spannableString.getSpanEnd(spanCandidate);
                    CharSequence sequence = spannableString.subSequence(start, end);
                    if (textToClick.toString().equals(sequence.toString())) {
                        span.onClick(textView);
                        return;
                    }
                }
            }

            // textToClick not found in TextView
            throw new NoMatchingViewException.Builder()
                    .includeViewHierarchy(true)
                    .withRootView(textView)
                    .build();

        }
    };
}
 
Example 36
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineOffsetFunctionTrunkBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(Trunk.BASE_LAYER_ID);
      assertNotNull(layer.getLineOffset());
      assertNotNull(layer.getLineOffset().getFunction());
      assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001);
      assertEquals(4, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size());
    }
  });
}
 
Example 37
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineWidthFunctionTrunkCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(Trunk.CASE_LAYER_ID);
      assertNotNull(layer.getLineWidth());
      assertNotNull(layer.getLineWidth().getFunction());
      assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001);
      assertEquals(4, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size());
    }
  });
}
 
Example 38
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineWidthFunctionMotorwayCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(MotorWay.CASE_LAYER_ID);
      assertNotNull(layer.getLineWidth());
      assertNotNull(layer.getLineWidth().getFunction());
      assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001);
      assertEquals(4, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size());
    }
  });
}
 
Example 39
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineJoinLocalBaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Local.BASE_LAYER_ID)).getLineJoin().getValue());
    }
  });
}
 
Example 40
Project: mapbox-plugins-android   File: TrafficPluginTest.java   View source code 5 votes vote down vote up
@Test
public void lineWidthFunctionPrimaryCaseLayer() throws Exception {
  executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
    @Override
    public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
      LineLayer layer = mapboxMap.getLayerAs(Primary.CASE_LAYER_ID);
      assertNotNull(layer.getLineWidth());
      assertNotNull(layer.getLineWidth().getFunction());
      assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass());
      assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass());
      assertEquals(1.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001);
      assertEquals(3, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size());
    }
  });
}