How to use matches method of Drivers Package

Best Unobtainium_ruby code snippet using Drivers.matches

DriverTracker.java

Source:DriverTracker.java Github

copy

Full Screen

...36 /** DeviceManager object. */37 protected Activator manager;38 /** Dictionary mapping Driver ID String =>39 * Hashtable (Device ServiceReference => cached Match objects) */40 protected Hashtable<String, Hashtable<ServiceReference, Match>> matches;41 /** Dictionary mapping Driver ID String =>42 * Hashtable (Device ServiceReference => cached referral String) */43 protected Hashtable<String, Hashtable<ServiceReference, String>> referrals;44 /**45 * Create the DriverTracker.46 *47 * @param manager DeviceManager object.48 * @param device DeviceTracker we are working for.49 */50 public DriverTracker(Activator manager) {51 super(manager.context, clazz, null);52 this.manager = manager;53 log = manager.log;54 drivers = new Hashtable<>(37);55 matches = new Hashtable<>(37);56 referrals = new Hashtable<>(37);57 if (Activator.DEBUG) {58 log.log(LogService.LOG_DEBUG, this + " constructor"); //$NON-NLS-1$59 }60 open();61 }62 /**63 * A service is being added to the ServiceTracker.64 *65 * <p>This method is called before a service which matched66 * the search parameters of the ServiceTracker is67 * added to the ServiceTracker. This method should return the68 * service object to be tracked for this ServiceReference.69 * The returned service object is stored in the ServiceTracker70 * and is available from the getService and getServices71 * methods.72 *73 * @param reference Reference to service being added to the ServiceTracker.74 * @return The service object to be tracked for the75 * ServiceReference or <tt>null</tt> if the ServiceReference should not76 * be tracked.77 */78 public Object addingService(ServiceReference reference) {79 if (Activator.DEBUG) {80 log.log(reference, LogService.LOG_DEBUG, this + " adding service"); //$NON-NLS-1$81 }82 String driver_id = getDriverID(reference);83 if (drivers.get(driver_id) != null) {84 log.log(reference, LogService.LOG_WARNING, NLS.bind(DeviceMsg.Multiple_Driver_services_with_the_same_DRIVER_ID, driver_id));85 return (null); /* don't track this driver */86 }87 drivers.put(driver_id, reference);88 drivers.put(reference, driver_id);89 manager.driverServiceRegistered = true;90 /* OSGi SPR2 Device Access 1.191 * Section 8.4.3 - When a new Driver service is registered,92 * the Device Attachment Algorithm must be applied to all93 * idle Device services.94 *95 * We do not refine idle Devices when the manager has not fully96 * started or the Driver service is from a bundle just installed97 * by the devicemanager.98 */99 Bundle bundle = reference.getBundle();100 if (manager.running && !manager.locators.isUninstallCandidate(bundle)) {101 manager.refineIdleDevices();102 }103 return (context.getService(reference));104 }105 /**106 * A service tracked by the ServiceTracker has been modified.107 *108 * <p>This method is called when a service being tracked109 * by the ServiceTracker has had it properties modified.110 *111 * @param reference Reference to service that has been modified.112 * @param service The service object for the modified service.113 */114 public void modifiedService(ServiceReference reference, Object service) {115 if (Activator.DEBUG) {116 log.log(reference, LogService.LOG_DEBUG, this + " modified service"); //$NON-NLS-1$117 }118 String driver_id = getDriverID(reference);119 String old_id = (String) drivers.get(reference);120 if (!driver_id.equals(old_id)) {121 drivers.put(driver_id, reference);122 drivers.put(reference, driver_id);123 drivers.remove(old_id);124 }125 }126 /**127 * A service tracked by the ServiceTracker is being removed.128 *129 * <p>This method is called after a service is no longer being tracked130 * by the ServiceTracker.131 *132 * @param reference Reference to service that has been removed.133 * @param service The service object for the removed service.134 */135 public void removedService(ServiceReference reference, Object service) {136 if (Activator.DEBUG) {137 log.log(reference, LogService.LOG_DEBUG, this + " removing service"); //$NON-NLS-1$138 }139 String driver_id = getDriverID(reference);140 drivers.remove(driver_id);141 drivers.remove(reference);142 matches.remove(driver_id);143 referrals.remove(driver_id);144 context.ungetService(reference);145 /* OSGi SPR2 Device Access 1.1146 * Section 8.4.4 - When a Driver service is unregistered,147 * the Device Attachment Algorithm must be applied to all148 * idle Device services.149 *150 * We do not refine idle Devices when the manager has not fully151 * started or the Driver service is from a bundle just installed152 * by the devicemanager.153 */154 Bundle bundle = reference.getBundle();155 if (manager.running && !manager.locators.isUninstallCandidate(bundle)) {156 DriverUpdate update = new DriverUpdate(bundle, manager);157 Thread thread = (new SecureAction()).createThread(update, DeviceMsg.DeviceManager_Update_Wait);158 thread.start();159 }160 }161 /**162 * Return the DRIVER_ID string for a ServiceReference.163 *164 * Per Section 8.4.3 of the OSGi SP R2 spec,165 * "A Driver service registration must have a DRIVER_ID property"166 *167 * This method is somewhat more lenient. If no DRIVER_ID property168 * is set, it will use the Bundle's location instead.169 *170 * @param reference Reference to driver service.171 * @return DRIVER_ID string.172 */173 public String getDriverID(final ServiceReference reference) {174 String driver_id = (String) reference.getProperty(org.osgi.service.device.Constants.DRIVER_ID);175 if (driver_id == null) {176 log.log(reference, LogService.LOG_WARNING, DeviceMsg.Driver_service_has_no_DRIVER_ID);177 driver_id = AccessController.doPrivileged((PrivilegedAction<String>) () -> reference.getBundle().getLocation());178 }179 return (driver_id);180 }181 /**182 * Get the ServiceReference for a given DRIVER_ID.183 *184 * @param driver_id185 * @return ServiceReference to a Driver service.186 */187 public ServiceReference getDriver(String driver_id) {188 return ((ServiceReference) drivers.get(driver_id));189 }190 /**191 * Search the driver list to find the best match for the device.192 *193 * @return ServiceReference to best matched Driver or null of their is no match.194 */195 public ServiceReference match(ServiceReference device, Vector exclude) {196 if (Activator.DEBUG) {197 log.log(device, LogService.LOG_DEBUG, this + ": Driver match called"); //$NON-NLS-1$198 }199 ServiceReference[] references = getServiceReferences();200 if (references != null) {201 int size = references.length;202 Vector<Match> successfulMatches = new Vector<>(size);203 for (int i = 0; i < size; i++) {204 ServiceReference driver = references[i];205 if (exclude.contains(driver)) {206 if (Activator.DEBUG) {207 log.log(driver, LogService.LOG_DEBUG, this + ": Driver match excluded: " + drivers.get(driver)); //$NON-NLS-1$208 }209 } else {210 if (Activator.DEBUG) {211 log.log(driver, LogService.LOG_DEBUG, this + ": Driver match called: " + drivers.get(driver)); //$NON-NLS-1$212 }213 Match match = getMatch(driver, device);214 if (match == null) {215 Driver service = (Driver) getService(driver);216 if (service == null) {217 continue;218 }219 int matchValue = Device.MATCH_NONE;220 try {221 matchValue = service.match(device);222 } catch (Throwable t) {223 log.log(driver, LogService.LOG_ERROR, DeviceMsg.Driver_error_during_match, t);224 continue;225 }226 if (Activator.DEBUG) {227 log.log(driver, LogService.LOG_DEBUG, this + ": Driver match value: " + matchValue); //$NON-NLS-1$228 }229 match = new Match(driver, matchValue);230 storeMatch(driver, device, match);231 }232 if (match.getMatchValue() > Device.MATCH_NONE) {233 successfulMatches.addElement(match);234 }235 }236 }237 size = successfulMatches.size();238 if (size > 0) {239 Match[] matchArray = new Match[size];240 successfulMatches.copyInto(matchArray);241 return manager.selectors.select(device, matchArray);242 }243 }244 return null;245 }246 public Match getMatch(ServiceReference driver, ServiceReference device) {247 String driverid = getDriverID(driver);248 Hashtable<ServiceReference, Match> driverMatches = matches.get(driverid);249 if (driverMatches == null) {250 return null;251 }252 return driverMatches.get(device);253 }254 public void storeMatch(ServiceReference driver, ServiceReference device, Match match) {255 String driverid = getDriverID(driver);256 Hashtable<ServiceReference, Match> driverMatches = matches.get(driverid);257 if (driverMatches == null) {258 driverMatches = new Hashtable<>(37);259 matches.put(driverid, driverMatches);260 }261 driverMatches.put(device, match);262 }263 /**264 * Attempt to attach the driver to the device. If the driver265 * refers, add the referred driver to the driver list.266 *267 * @param driver Driver to attach268 * @param device Device to be attached269 * @return true is the Driver successfully attached.270 */271 public boolean attach(ServiceReference driver, ServiceReference device, Vector exclude) {272 if (Activator.DEBUG) {273 log.log(driver, LogService.LOG_DEBUG, this + ": Driver attach called: " + drivers.get(driver)); //$NON-NLS-1$...

Full Screen

Full Screen

DetailDriverFragmentLandScapeTest.java

Source:DetailDriverFragmentLandScapeTest.java Github

copy

Full Screen

...22import static android.support.test.espresso.Espresso.onData;23import static android.support.test.espresso.Espresso.onView;24import static android.support.test.espresso.action.ViewActions.click;25import static android.support.test.espresso.action.ViewActions.swipeDown;26import static android.support.test.espresso.assertion.ViewAssertions.matches;27import static android.support.test.espresso.contrib.DrawerActions.open;28import static android.support.test.espresso.contrib.DrawerMatchers.isClosed;29import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;30import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;31import static android.support.test.espresso.matcher.ViewMatchers.isRoot;32import static android.support.test.espresso.matcher.ViewMatchers.withId;33import static android.support.test.espresso.matcher.ViewMatchers.withText;34import static android.support.test.espresso.web.assertion.WebViewAssertions.webMatches;35import static android.support.test.espresso.web.model.Atoms.getCurrentUrl;36import static android.support.test.espresso.web.sugar.Web.onWebView;37import static com.gmail.fattazzo.formula1world.matchers.Matchers.withChildViewCount;38import static com.gmail.fattazzo.formula1world.matchers.Matchers.withIndex;39import static org.hamcrest.Matchers.anything;40import static org.hamcrest.Matchers.containsString;41/**42 * @author fattazzo43 * <p/>44 * date: 05/09/1745 */46@LargeTest47public class DetailDriverFragmentLandScapeTest extends BaseTest {48 @Test49 public void testProgressLandscape() {50 rotateLandscape();51 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {52 testSeasonProgress(i);53 }54 }55 @Test56 public void testRankingLandscape() {57 rotateLandscape();58 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {59 testSeasonRanking(i);60 }61 }62 @Test63 public void testInfoLandscape() {64 rotateLandscape();65 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {66 testSeasonInfo(i);67 }68 }69 @Test70 public void testVettel2016() {71 F1Driver vettel = new F1Driver();72 vettel.setDriverRef("vettel");73 Ergast ergast = Ergast_.getInstance_(getContext());74 ergast.setSeason(2016);75 DataService dataService = DataService_.getInstance_(getContext());76 List<F1Result> vettelResults = dataService.loadDriverRacesResult(vettel);77 selectSeason(2016);78 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());79 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));80 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(20).onChildView(withId(R.id.driver_item_name)).check(matches(withText("Sebastian Vettel")));81 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(20).onChildView(withId(R.id.driver_item_name)).perform(click());82 onView(withId(R.id.title)).check(matches(withText("Sebastian Vettel")));83 // Progress84 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_season_progress_tab_title)))));85 onView(withId(R.id.progress_driver_table_layout)).check(matches(withChildViewCount(vettelResults.size() + 1, null)));86 int pos = 0;87 for (F1Result result : vettelResults) {88 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));89 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));90 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));91 String time = "-";92 if (result.getTime() != null) {93 time = StringUtils.defaultString(result.getTime().getTime(), "-");94 }95 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));96 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));97 pos++;98 }99 onView(withId(R.id.swipe_refresh_layout)).perform(swipeDown());100 pos = 0;101 for (F1Result result : vettelResults) {102 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));103 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));104 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));105 String time = "-";106 if (result.getTime() != null) {107 time = StringUtils.defaultString(result.getTime().getTime(), "-");108 }109 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));110 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));111 pos++;112 }113 // Classifica114 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title});115 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_ranking_tab_title)))));116 // Info117 swipeViewPager(R.id.view_pager, new int[]{R.string.info_fragment_title});118 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.info_fragment_title)))));119 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title, R.string.detail_driver_season_progress_tab_title});120 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_season_progress_tab_title)))));121 }122 private void testSeasonProgress(int season) {123 selectSeason(season);124 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());125 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));126 Ergast ergast = Ergast_.getInstance_(getContext());127 ergast.setSeason(season);128 DataService dataService = DataService_.getInstance_(getContext());129 List<F1Driver> drivers = new ArrayList<>();130 drivers.addAll(dataService.loadDrivers());131 Collections.sort(drivers, new DriverNameComparator());132 for (int i = 0; i <= drivers.size() - 1; i++) {133 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());134 List<F1Result> driverResults = dataService.loadDriverRacesResult(drivers.get(i));135 int pos = 0;136 for (F1Result result : driverResults) {137 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));138 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));139 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));140 String time = "-";141 if (result.getTime() != null) {142 time = StringUtils.defaultString(result.getTime().getTime(), "-");143 }144 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));145 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));146 pos++;147 }148 try {149 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));150 // Large screen display, no need pressBack151 } catch (Exception e) {152 onView(isRoot()).perform(ViewActions.pressBack());153 }154 }155 }156 private void testSeasonRanking(int season) {157 selectSeason(season);158 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());159 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));160 Ergast ergast = Ergast_.getInstance_(getContext());161 ergast.setSeason(season);162 DataService dataService = DataService_.getInstance_(getContext());163 List<F1Driver> drivers = new ArrayList<>();164 drivers.addAll(dataService.loadDrivers());165 Collections.sort(drivers, new DriverNameComparator());166 for (int i = 0; i <= drivers.size() - 1; i++) {167 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());168 WaitAction.waitFor(100);169 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title});170 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_ranking_tab_title)))));171 onView(withId(R.id.textView2)).check(matches(withText(getContext().getString(R.string.detail_driver_positions_chart))));172 onView(withId(R.id.textView3)).check(matches(withText(getContext().getString(R.string.detail_driver_points_chart))));173 try {174 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));175 // Large screen display, no need pressBack176 } catch (Exception e) {177 onView(isRoot()).perform(ViewActions.pressBack());178 }179 }180 }181 private void testSeasonInfo(int season) {182 selectSeason(season);183 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());184 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));185 Ergast ergast = Ergast_.getInstance_(getContext());186 ergast.setSeason(season);187 DataService dataService = DataService_.getInstance_(getContext());188 List<F1Driver> drivers = new ArrayList<>();189 drivers.addAll(dataService.loadDrivers());190 Collections.sort(drivers, new DriverNameComparator());191 for (int i = 0; i <= drivers.size() - 1; i++) {192 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());193 WaitAction.waitFor(100);194 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title, R.string.info_fragment_title});195 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.info_fragment_title)))));196 onWebView(withId(R.id.webview)).check(webMatches(getCurrentUrl(), containsString(StringUtils.substringAfterLast(drivers.get(i).getFamilyName(), " "))));197 onWebView(withId(R.id.webview)).check(webMatches(getCurrentUrl(), containsString(StringUtils.substringAfterLast(drivers.get(i).getGivenName(), " "))));198 //onWebView(withId(R.id.webview)).withElement(findElement(Locator.ID, "firstHeading")).check(webMatches(getText(), containsString(drivers.get(i).familyName)));199 //onWebView(withId(R.id.webview)).withElement(findElement(Locator.ID, "firstHeading")).check(webMatches(getText(), containsString(drivers.get(i).givenName)));200 try {201 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));202 // Large screen display, no need pressBack203 } catch (Exception e) {204 onView(isRoot()).perform(ViewActions.pressBack());205 }206 }207 }208}...

Full Screen

Full Screen

DetailDriverFragmentTest.java

Source:DetailDriverFragmentTest.java Github

copy

Full Screen

...22import static android.support.test.espresso.Espresso.onData;23import static android.support.test.espresso.Espresso.onView;24import static android.support.test.espresso.action.ViewActions.click;25import static android.support.test.espresso.action.ViewActions.swipeDown;26import static android.support.test.espresso.assertion.ViewAssertions.matches;27import static android.support.test.espresso.contrib.DrawerActions.open;28import static android.support.test.espresso.contrib.DrawerMatchers.isClosed;29import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;30import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;31import static android.support.test.espresso.matcher.ViewMatchers.isRoot;32import static android.support.test.espresso.matcher.ViewMatchers.withId;33import static android.support.test.espresso.matcher.ViewMatchers.withText;34import static android.support.test.espresso.web.assertion.WebViewAssertions.webMatches;35import static android.support.test.espresso.web.model.Atoms.getCurrentUrl;36import static android.support.test.espresso.web.sugar.Web.onWebView;37import static com.gmail.fattazzo.formula1world.matchers.Matchers.withChildViewCount;38import static com.gmail.fattazzo.formula1world.matchers.Matchers.withIndex;39import static org.hamcrest.Matchers.anything;40import static org.hamcrest.Matchers.containsString;41/**42 * @author fattazzo43 * <p/>44 * date: 05/09/1745 */46@LargeTest47public class DetailDriverFragmentTest extends BaseTest {48 @Test49 public void testProgressPortrait() {50 rotatePortrait();51 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {52 testSeasonProgress(i);53 }54 }55 @Test56 public void testRankingPortrait() {57 rotatePortrait();58 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {59 testSeasonRanking(i);60 }61 }62 @Test63 public void testInfoPortrait() {64 rotatePortrait();65 for (int i = TestConfig.getStartYear(); i <= getLastAvailableSeason(); i++) {66 testSeasonInfo(i);67 }68 }69 @Test70 public void testVettel2016() {71 F1Driver vettel = new F1Driver();72 vettel.setDriverRef("vettel");73 Ergast ergast = Ergast_.getInstance_(getContext());74 ergast.setSeason(2016);75 DataService dataService = DataService_.getInstance_(getContext());76 List<F1Result> vettelResults = dataService.loadDriverRacesResult(vettel);77 selectSeason(2016);78 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());79 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));80 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(20).onChildView(withId(R.id.driver_item_name)).check(matches(withText("Sebastian Vettel")));81 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(20).onChildView(withId(R.id.driver_item_name)).perform(click());82 onView(withId(R.id.title)).check(matches(withText("Sebastian Vettel")));83 // Progress84 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_season_progress_tab_title)))));85 onView(withId(R.id.progress_driver_table_layout)).check(matches(withChildViewCount(vettelResults.size() + 1, null)));86 int pos = 0;87 for (F1Result result : vettelResults) {88 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));89 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));90 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));91 String time = "-";92 if (result.getTime() != null) {93 time = StringUtils.defaultString(result.getTime().getTime(), "-");94 }95 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));96 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));97 pos++;98 }99 onView(withId(R.id.swipe_refresh_layout)).perform(swipeDown());100 pos = 0;101 for (F1Result result : vettelResults) {102 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));103 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));104 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));105 String time = "-";106 if (result.getTime() != null) {107 time = StringUtils.defaultString(result.getTime().getTime(), "-");108 }109 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));110 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));111 pos++;112 }113 // Classifica114 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title});115 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_ranking_tab_title)))));116 // Info117 swipeViewPager(R.id.view_pager, new int[]{R.string.info_fragment_title});118 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.info_fragment_title)))));119 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title, R.string.detail_driver_season_progress_tab_title});120 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_season_progress_tab_title)))));121 }122 private void testSeasonProgress(int season) {123 selectSeason(season);124 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());125 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));126 Ergast ergast = Ergast_.getInstance_(getContext());127 ergast.setSeason(season);128 DataService dataService = DataService_.getInstance_(getContext());129 List<F1Driver> drivers = new ArrayList<>();130 drivers.addAll(dataService.loadDrivers());131 Collections.sort(drivers, new DriverNameComparator());132 for (int i = 0; i <= drivers.size() - 1; i++) {133 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());134 List<F1Result> driverResults = dataService.loadDriverRacesResult(drivers.get(i));135 int pos = 0;136 for (F1Result result : driverResults) {137 onView(withIndex(withId(R.id.race_results_position), pos)).check(matches(withText(result.getPositionText())));138 onView(withIndex(withId(R.id.race_results_laps), pos)).check(matches(withText(String.valueOf(result.getLaps()))));139 onView(withIndex(withId(R.id.race_results_grid), pos)).check(matches(withText(String.valueOf(result.getGrid()))));140 String time = "-";141 if (result.getTime() != null) {142 time = StringUtils.defaultString(result.getTime().getTime(), "-");143 }144 onView(withIndex(withId(R.id.race_results_time), pos)).check(matches(withText(time)));145 onView(withIndex(withId(R.id.race_results_status), pos)).check(matches(withText(result.getStatus())));146 pos++;147 }148 try {149 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));150 // Large screen display, no need pressBack151 } catch (Exception e) {152 onView(isRoot()).perform(ViewActions.pressBack());153 }154 }155 }156 private void testSeasonRanking(int season) {157 selectSeason(season);158 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());159 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));160 Ergast ergast = Ergast_.getInstance_(getContext());161 ergast.setSeason(season);162 DataService dataService = DataService_.getInstance_(getContext());163 List<F1Driver> drivers = new ArrayList<>();164 drivers.addAll(dataService.loadDrivers());165 Collections.sort(drivers, new DriverNameComparator());166 for (int i = 0; i <= drivers.size() - 1; i++) {167 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());168 WaitAction.waitFor(100);169 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title});170 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.detail_driver_ranking_tab_title)))));171 onView(withId(R.id.textView2)).check(matches(withText(getContext().getString(R.string.detail_driver_positions_chart))));172 onView(withId(R.id.textView3)).check(matches(withText(getContext().getString(R.string.detail_driver_points_chart))));173 try {174 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));175 // Large screen display, no need pressBack176 } catch (Exception e) {177 onView(isRoot()).perform(ViewActions.pressBack());178 }179 }180 }181 private void testSeasonInfo(int season) {182 selectSeason(season);183 onView(withId(R.id.drawer_layout)).check(matches(isClosed(Gravity.START))).perform(open());184 onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_current_season_driver));185 Ergast ergast = Ergast_.getInstance_(getContext());186 ergast.setSeason(season);187 DataService dataService = DataService_.getInstance_(getContext());188 List<F1Driver> drivers = new ArrayList<>();189 drivers.addAll(dataService.loadDrivers());190 Collections.sort(drivers, new DriverNameComparator());191 for (int i = 0; i <= drivers.size() - 1; i++) {192 onData(anything()).inAdapterView(withId(R.id.list_view)).atPosition(i).onChildView(withId(R.id.driver_item_name)).perform(click());193 WaitAction.waitFor(100);194 swipeViewPager(R.id.view_pager, new int[]{R.string.detail_driver_ranking_tab_title, R.string.info_fragment_title});195 onView(withId(R.id.view_pager)).check(matches(hasDescendant(withText(getContext().getString(R.string.info_fragment_title)))));196 onWebView(withId(R.id.webview)).check(webMatches(getCurrentUrl(), containsString(StringUtils.substringAfterLast(drivers.get(i).getFamilyName(), " "))));197 onWebView(withId(R.id.webview)).check(webMatches(getCurrentUrl(), containsString(StringUtils.substringAfterLast(drivers.get(i).getGivenName(), " "))));198 //onWebView(withId(R.id.webview)).withElement(findElement(Locator.ID, "firstHeading")).check(webMatches(getText(), containsString(drivers.get(i).familyName)));199 //onWebView(withId(R.id.webview)).withElement(findElement(Locator.ID, "firstHeading")).check(webMatches(getText(), containsString(drivers.get(i).givenName)));200 try {201 onView(withId(R.id.details_fragment_container)).check(matches(isDisplayed()));202 // Large screen display, no need pressBack203 } catch (Exception e) {204 onView(isRoot()).perform(ViewActions.pressBack());205 }206 }207 }208}...

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1driver = Drivers.new(driver_name, car_name, license_number, car_number)2driver1 = Drivers.new(driver_name, car_name, license_number, car_number)3driver2 = Drivers.new(driver_name, car_name, license_number, car_number)4driver3 = Drivers.new(driver_name, car_name, license_number, car_number)5driver4 = Drivers.new(driver_name, car_name, license_number, car_number)6if driver4.matches(drivers)

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1driver = Driver.new("John", "Smith")2puts driver.matches("John", "Smith")3puts driver.matches("John", "Smithy")4puts driver.matches("Johnny", "Smith")5puts driver.matches("Johnny", "Smithy")

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1drivers.matches("Rajesh")2drivers.matches("Ramesh")3drivers.matches("Rajesh")4drivers.matches("Rajesh")5drivers.matches("Ramesh")6drivers.matches("Ramesh")7drivers.matches("Ramesh")8drivers.matches("Ramesh")9drivers.matches("Rajesh")10drivers.matches("Rajesh")11drivers.matches("Ramesh")12drivers.matches("Rajesh")13drivers.matches("Ramesh")14drivers.matches("Ramesh")15drivers.matches("Ramesh")16drivers.matches("Ramesh")17drivers.matches("Rajesh")18drivers.matches("Rajesh")19drivers.matches("Ramesh")20drivers.matches("Rajesh")21drivers.matches("Ramesh")22drivers.matches("Ramesh")23drivers.matches("Ramesh")24drivers.matches("Ramesh")25drivers.matches("Rajesh")26drivers.matches("Rajesh")27drivers.matches("Ramesh")28drivers.matches("Rajesh")29drivers.matches("Ramesh")30drivers.matches("Ramesh")31drivers.matches("Ramesh")32drivers.matches("Ramesh")33drivers.matches("Rajesh")34drivers.matches("Rajesh")35drivers.matches("Ramesh")36drivers.matches("Rajesh")37drivers.matches("Ramesh")38drivers.matches("Ramesh")39drivers.matches("Ramesh")40drivers.matches("Ramesh")41drivers.matches("Rajesh")42drivers.matches("Rajesh")43drivers.matches("Ramesh")44drivers.matches("Rajesh")45drivers.matches("Ramesh")46drivers.matches("Ramesh")47drivers.matches("Ramesh")48drivers.matches("Ramesh")49drivers.matches("Rajesh")50drivers.matches("Rajesh")51drivers.matches("Ramesh")52drivers.matches("Rajesh")53drivers.matches("Ramesh")54drivers.matches("Ramesh")55drivers.matches("Ramesh")56drivers.matches("Ramesh")57drivers.matches("Rajesh")58drivers.matches("Rajesh")59drivers.matches("Ramesh")60drivers.matches("Rajesh")61drivers.matches("Ramesh")62drivers.matches("Ramesh")63drivers.matches("Ramesh")64drivers.matches("Ramesh")65drivers.matches("Rajesh")66drivers.matches("Rajesh")67drivers.matches("Ramesh")68drivers.matches("Rajesh")69drivers.matches("Ramesh")70drivers.matches("Rames

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1drivers.add_driver('1', 'John', 'Smith')2drivers.add_driver('2', 'Jane', 'Doe')3drivers.add_driver('3', 'Alex', 'Smith')4drivers.add_driver('4', 'Jane', 'Smith')5drivers.add_driver('5', 'John', 'Doe')6puts drivers.matches('John', 'Smith')7puts drivers.matches('Jane', 'Doe')8puts drivers.matches('Alex', 'Smith')9puts drivers.matches('Jane', 'Smith')10puts drivers.matches('John', 'Doe')11puts drivers.matches('John', 'Alex')

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1driver1 = Drivers.new("John", "Smith", 123456)2driver2 = Drivers.new("Jane", "Doe", 654321)3driver3 = Drivers.new("John", "Smith", 123456)4car1 = Cars.new("Toyota", "Camry", 2007, "Green")5car2 = Cars.new("Honda", "Accord", 2005, "Blue")

Full Screen

Full Screen

matches

Using AI Code Generation

copy

Full Screen

1drivers.add('John', 'Smith')2drivers.add('John', 'Doe')3drivers.add('Jane', 'Doe')4drivers.add('Jack', 'Sparrow')5drivers.add('Jack', 'Bauer')6drivers.add('Jack', 'Daniels')7p drivers.matches('John', 'Smith')8p drivers.matches('Jack')9p drivers.matches('John', 'Doe')10p drivers.matches('Jack', 'Bauer')11p drivers.matches('Jack', 'Daniels')12p drivers.matches('John', 'Doe', 'Jack', 'Daniels')13p drivers.matches('John', 'Doe', 'Jack', 'Bauer')14p drivers.matches('Jack', 'Daniels', 'John', 'Doe')15p drivers.matches('Jack', 'Daniels', 'John', 'Doe', 'Jack', 'Bauer')16p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer')17p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith')18p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith', 'Jane', 'Doe')19p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith', 'Jane', 'Doe', 'Jack', 'Sparrow')20p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith', 'Jane', 'Doe', 'Jack', 'Sparrow', 'John', 'Doe')21p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith', 'Jane', 'Doe', 'Jack', 'Sparrow', 'John', 'Doe', 'Jack', 'Bauer')22p drivers.matches('John', 'Doe', 'Jack', 'Daniels', 'Jack', 'Bauer', 'John', 'Smith', 'Jane', 'Doe', 'Jack', 'Sparrow', 'John', 'Doe', 'Jack', '

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Unobtainium_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful