New issue
Advanced search Search tips

Issue 884211 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Nov 12
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task

Blocking:
issue 914423



Sign in to add a comment

Write integration tests for BrowserSwitcher

Project Member Reported by nicolaso@chromium.org, Sep 14

Issue description

We have reasonable unit test coverage, but there are parts of BrowserSwitcher that are hard to test without integration tests. Those can give us confidence that the whole feature works as intended.

In particular, AlternativeBrowserDriver does a lot of I/O, and is platform specific. This makes it difficult to write unit tests, and is a good candidate for integration testing.

We could write a test that checks that BrowserSwitcher runs a command line as configured by the admin. In order to do this without changing AlternativeBrowserDriver internals too much, we can:

- In the unit test, configure BrowserSwitcher's "alternative browser" to run a script that writes the URL to a temporary file.
- Wait for a set amount of time, then check that the file has been created with the right content.

e.g. the configuration could be something like

  "browser_switcher": {
    "url_list": ["example.com"],
    "alternative_browser_path": "/bin/sh",
    "alternative_browser_parameters": ["-c", "echo ${url} >/tmp/fooXXX.txt"]
  }
 
Project Member

Comment 1 by bugdroid1@chromium.org, Nov 12

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9f85dcc794c0e1e881dba32a2cee894fc14fc6b0

commit 9f85dcc794c0e1e881dba32a2cee894fc14fc6b0
Author: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Date: Mon Nov 12 16:01:39 2018

[BrowserSwitcher] Add integration tests

The test runs an 'echo' command to a temporary file when the user visits
example.com, and then checks that the temporary file exists and contains
the right string.

Bug:  884211 
Change-Id: Ifa8a129aa8e98583a6060274bb85a8bc4d235b8d
Reviewed-on: https://chromium-review.googlesource.com/c/1318057
Reviewed-by: Julian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607242}
[add] https://crrev.com/9f85dcc794c0e1e881dba32a2cee894fc14fc6b0/chrome/browser/browser_switcher/browser_switcher_browsertest.cc
[modify] https://crrev.com/9f85dcc794c0e1e881dba32a2cee894fc14fc6b0/chrome/test/BUILD.gn

Status: Verified (was: Untriaged)

Sign in to add a comment