[Presentation API] Add layout test for connection.close() and fix test failures

Add layout test.

1-UA connection.close() hits NOTREACHED() in PresentationConnection::didChangeState(). Use PresentationConnection::didClose() instead.

BUG=697719

Review-Url: https://codereview.chromium.org/2730123003
Cr-Commit-Position: refs/heads/master@{#455225}
void PresentationConnection::didChangeState(
    WebPresentationConnectionState state,
    bool shouldDispatchEvent) {
  if (m_state == state)
    return;

  m_state = state;

  if (!shouldDispatchEvent)
    return;

  switch (m_state) {
    case WebPresentationConnectionState::Connecting:
      NOTREACHED();
      return;
    case WebPresentationConnectionState::Connected:
      dispatchStateChangeEvent(Event::create(EventTypeNames::connect));
      return;
    case WebPresentationConnectionState::Terminated:
      dispatchStateChangeEvent(Event::create(EventTypeNames::terminate));
      return;
    case WebPresentationConnectionState::Closed:
      NOTREACHED();
      return;
  }
  NOTREACHED();
}

void PresentationConnection::didChangeState(
    WebPresentationConnectionState state,
    bool shouldDispatchEvent) {
  if (m_state == state)
    return;

  m_state = state;

  if (!shouldDispatchEvent)
    return;

  switch (m_state) {
    case WebPresentationConnectionState::Connecting:
      NOTREACHED();
      return;
    case WebPresentationConnectionState::Connected:
      dispatchStateChangeEvent(Event::create(EventTypeNames::connect));
      return;
    case WebPresentationConnectionState::Terminated:
      dispatchStateChangeEvent(Event::create(EventTypeNames::terminate));
      return;
    case WebPresentationConnectionState::Closed:
      NOTREACHED();
      return;
  }
  NOTREACHED();
}
