function verifySend(
    sendMethod, expectedStatusCode = 200, isStream = false,
    isArrayBuffer = false, isStreamBinaryChunks = false) {
  return new Promise((resolve, reject) => {
    const xhr = factory.createInstance();
    const expectedBody = 'responseBody';
    if (isArrayBuffer) {
      xhr.responseType = 'arraybuffer';
    }
    xhr.open(sendMethod, 'https://www.google.com', true /* opt_async */);
    let lastState;
    let lastBufferSize = 0;
    let numberOfUpdates = 0;
    /**
     * @suppress {strictMissingProperties} suppression added to enable type
     * checking
     */
    xhr.onreadystatechange = () => {
      if (xhr.readyState === FetchXmlHttp.RequestState.HEADER_RECEIVED) {
        lastState = xhr.readyState;
        let expectedHeaders =
            'dummyheader: dummyHeaderValue\r\ndummyheader2: dummyHeaderValue2';
        if (!isStream && !isArrayBuffer) {
          expectedHeaders =
              `content-type: text/plain;charset=UTF-8\r\n${expectedHeaders}`;
        }
        assertEquals(expectedStatusCode, xhr.status);
        assertEquals('', xhr.responseText);
        assertEquals('dummyHeaderValue', xhr.getResponseHeader('dummyHeader'));
        assertEquals(expectedHeaders, xhr.getAllResponseHeaders());
      } else if (xhr.readyState === FetchXmlHttp.RequestState.LOADING) {
        lastState = xhr.readyState;
        assertEquals(expectedStatusCode, xhr.status);
        assertEquals(0, expectedBody.indexOf(xhr.responseText));
        if (isStream && xhr.responseText) {
          assertTrue(xhr.responseText.length > lastBufferSize);
          lastBufferSize = xhr.responseText.length;
          numberOfUpdates++;
        }
      } else if (xhr.readyState === FetchXmlHttp.RequestState.DONE) {
        assertEquals(FetchXmlHttp.RequestState.LOADING, lastState);
        assertEquals(expectedStatusCode, xhr.status);
        if (isArrayBuffer) {
          assertTrue(xhr.response instanceof ArrayBuffer);
          assertEquals(8, xhr.response.byteLength);
        } else if (!isStreamBinaryChunks) {
          assertEquals(expectedBody, xhr.responseText);
        }
        if (isStreamBinaryChunks) {
          const bytes = new TextEncoder().encode('responseBody');
          assertEquals(bytes.length, xhr.response.length);
          assertTrue((xhr.response)[0] instanceof Uint8Array);
          for (let i = 0; i < bytes.length; i++) {
            assertTrue(bytes[i] === xhr.response[i][0]);
          }
        } else if (isStream) {
          assertEquals(expectedBody.length, numberOfUpdates);
        }
        resolve();
      } else {
        reject(new Error('Unexpected request state ' + xhr.readyState));
      }
    };
    xhr.send();
    assertEquals(xhr.readyState, FetchXmlHttp.RequestState.OPENED);

    mockControl.$verifyAll();
  });
}
Util function to verify send method.
@param {string} sendMethod
@param {number=} expectedStatusCode
@param {boolean=} isStream
@param {boolean=} isArrayBuffer
@param {boolean=} isStreamBinaryChunks
@return {!Promise<void>}