Package org.uiautomation.ios.wkrdp.message

Examples of org.uiautomation.ios.wkrdp.message.ReportConnectedApplicationsMessage


      driver.setDevice(m.getDevice());
      sync.signalSimRegistered();
    }

    if (message instanceof ReportConnectedApplicationsMessage) {
      ReportConnectedApplicationsMessage m = (ReportConnectedApplicationsMessage) message;
      if (m.getApplications().size() == 0) {
        log.warning("ReportConnectedApplicationsMessage reported 0 app.");
      } else {
        driver.setApplications(m.getApplications());
        sync.signalSimSentApps();
      }

    }

    if (message instanceof ApplicationSentListingMessage) {
      ApplicationSentListingMessage m = (ApplicationSentListingMessage) message;

      List<WebkitPage> messagePages = m.getPages();
      List<WebkitPage> driverPages = driver.getPages();
      boolean equals = WebkitPage.equals(messagePages, driverPages);
      if (log.isLoggable(Level.FINE)) {
        log.fine(
            "pages " + (equals ? "equals" : "CHANGED") + ": " + driverPages + " -> " + messagePages
            + ": " + m);
      }
      if (equals) {
        // update the titles.
        driver.setPages(m.getPages());
        return;
      }

      if (session == null || session.getApplication().isSafari()) {
        int change = m.getPages().size() - driver.getPages().size();
        if (log.isLoggable(Level.FINE)) {
          log.fine(
              "ApplicationSentListingMessage: message pages: " + m.getPages().size() + ", change: "
              + change);
        }

        // a new page appeared. The driver needs to know.
        if (change > 0) {
          List<WebkitPage> pages = new ArrayList<WebkitPage>();
          // keep all the pages currently known to the driver
          pages.addAll(driver.getPages());

          // remove all the pages we already know of from the message
          for (WebkitPage p : driver.getPages()) {
            m.getPages().remove(p);
          }

          if (m.getPages().size() == 0) {
            throw new WebDriverException(m.getPages().size() + " new pages.");
          }

          // TODO there can be more than one 'new' UIWebView, picking the max one for now.
          WebkitPage newOne = Collections.max(m.getPages());
          pages.addAll(m.getPages());

          driver.setPages(pages);

          if (driver.getPages().size() == 0) {
            //log.fine("first page. Nothing to do.");
          } else if (newOne.isITunesAd()) {
            //log.fine("itunes ad - ignoring it.");
          } else {
            WebkitPage focus = newOne;

            if (session != null) {
              waitForWindowSwitchingAnimation();
              driver.switchTo(focus);
            } else {
              driver.switchTo(focus);
            }
          }
          // a page disappeared, the driver needs to know.
        } else if (change < 0) {
          List<WebkitPage> old = new ArrayList<WebkitPage>();
          old.addAll(driver.getPages());

          for (WebkitPage p : m.getPages()) {
            old.remove(p);
          }

          // TODO freynaud problem here.How to handle a window disappearing without loosing the state
          // of the currently selected page. driver.getPages() may need to become mutable again.
          // in the normal case, this is the page with the focus that is closed, so loosing the state
          // is ok. But for the extra window automatically closed ( ie the "there is an app for that
          // page, downlaod it on itune" page header, the header disappears when driver.get navigates
          // to a new page. The header disapeearing shouldn't impact the current state.
          for (WebkitPage p : old) {
            log.fine(
                "the page " + p + " has been deleted and must be removed from the driver cache");
            int currentFocus = driver.getCurrentPageID();
            if (p.getPageId() == currentFocus) {
              log.fine("the page deleted is the one with the focus.");
            } else {
              driver.setPages(m.getPages());
            }
          }
        }

        sync.signalSimSentPages();
      } else {
        driver.setPages(messagePages);
        if (messagePages.size() > 0) {
          if (session != null) {
            waitForWindowSwitchingAnimation();
          }
          WebkitPage focus = selectPage(driver.getPages());
          if (focus != null) {
            driver.switchTo(focus);
          }
        }
        sync.signalSimSentPages();
      }
    }

    if (message instanceof ApplicationDataMessage) {
      //ApplicationDataMessage m = (ApplicationDataMessage)message;
    }

    if (message instanceof ApplicationConnectedMessage) {
      ApplicationConnectedMessage m = (ApplicationConnectedMessage) message;
      List<WebkitApplication> apps = new ArrayList<WebkitApplication>();
      apps.add(m.getApplication());
      driver.setApplications(apps);
      sync.signalSimSentApps();
    }
  }
View Full Code Here

TOP

Related Classes of org.uiautomation.ios.wkrdp.message.ReportConnectedApplicationsMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.