Commit 429c261c authored by Sven Zheng's avatar Sven Zheng Committed by Commit Bot

Extract a base class for live tests

All new live tests should inherit from LiveTest.

Bug: 992143
Change-Id: Ic8f0d05275a2f3fd4ab8eec40d8cb21c5215f8b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1767087Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Sven Zheng <svenzheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698662}
parent e6ba6d2a
......@@ -2,60 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/signin/e2e_tests/live_test.h"
#include "chrome/browser/signin/e2e_tests/test_accounts_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/webui/signin/login_ui_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
using signin::test::TestAccount;
using signin::test::TestAccountsUtil;
base::FilePath::StringPieceType kTestAccountFilePath = FILE_PATH_LITERAL(
"chrome/browser/internal/resources/signin/test_accounts.json");
const char* kRunLiveTestFlag = "run-live-tests";
class DemoSignInTest : public InProcessBrowserTest {
protected:
void SetUpInProcessBrowserTestFixture() override {
// Whitelists a bunch of hosts.
host_resolver()->AllowDirectLookup("*.google.com");
host_resolver()->AllowDirectLookup("*.geotrust.com");
host_resolver()->AllowDirectLookup("*.gstatic.com");
host_resolver()->AllowDirectLookup("*.googleapis.com");
InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
}
void SetUp() override {
// Only run live tests when specified.
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(kRunLiveTestFlag)) {
GTEST_SKIP();
}
base::FilePath root_path;
base::PathService::Get(base::BasePathKey::DIR_SOURCE_ROOT, &root_path);
base::FilePath config_path =
base::MakeAbsoluteFilePath(root_path.Append(kTestAccountFilePath));
test_accounts_.Init(config_path);
InProcessBrowserTest::SetUp();
}
const TestAccountsUtil* GetTestAccountsUtil() const {
return &test_accounts_;
}
private:
TestAccountsUtil test_accounts_;
};
class DemoSignInTest : public signin::test::LiveTest {};
IN_PROC_BROWSER_TEST_F(DemoSignInTest, SimpleSignInFlow) {
// Always disable animation for stability.
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/e2e_tests/live_test.h"
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "net/dns/mock_host_resolver.h"
base::FilePath::StringPieceType kTestAccountFilePath = FILE_PATH_LITERAL(
"chrome/browser/internal/resources/signin/test_accounts.json");
const char* kRunLiveTestFlag = "run-live-tests";
namespace signin {
namespace test {
void LiveTest::SetUpInProcessBrowserTestFixture() {
// Whitelists a bunch of hosts.
host_resolver()->AllowDirectLookup("*.google.com");
host_resolver()->AllowDirectLookup("*.geotrust.com");
host_resolver()->AllowDirectLookup("*.gstatic.com");
host_resolver()->AllowDirectLookup("*.googleapis.com");
InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
}
void LiveTest::SetUp() {
// Only run live tests when specified.
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(kRunLiveTestFlag)) {
GTEST_SKIP();
}
base::FilePath root_path;
base::PathService::Get(base::BasePathKey::DIR_SOURCE_ROOT, &root_path);
base::FilePath config_path =
base::MakeAbsoluteFilePath(root_path.Append(kTestAccountFilePath));
test_accounts_.Init(config_path);
InProcessBrowserTest::SetUp();
}
} // namespace test
} // namespace signin
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_E2E_TESTS_LIVE_TEST_H_
#define CHROME_BROWSER_SIGNIN_E2E_TESTS_LIVE_TEST_H_
#include "chrome/browser/signin/e2e_tests/test_accounts_util.h"
#include "chrome/test/base/in_process_browser_test.h"
namespace signin {
namespace test {
class LiveTest : public InProcessBrowserTest {
protected:
void SetUpInProcessBrowserTestFixture() override;
void SetUp() override;
const TestAccountsUtil* GetTestAccountsUtil() const {
return &test_accounts_;
}
private:
TestAccountsUtil test_accounts_;
};
} // namespace test
} // namespace signin
#endif // CHROME_BROWSER_SIGNIN_E2E_TESTS_LIVE_TEST_H_
\ No newline at end of file
......@@ -1111,6 +1111,8 @@ if (!is_android) {
"../browser/sharing/click_to_call/click_to_call_browsertest.cc",
"../browser/signin/consistency_cookie_browsertest.cc",
"../browser/signin/e2e_tests/demo_signin_e2e_test.cc",
"../browser/signin/e2e_tests/live_test.cc",
"../browser/signin/e2e_tests/live_test.h",
"../browser/site_isolation/chrome_site_per_process_browsertest.cc",
"../browser/site_isolation/site_details_browsertest.cc",
"../browser/ui/blocked_content/popup_tracker_browsertest.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment