blob: e8d22189e73ad99cb872da7727bd56b4e18555be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// 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");
// Allows country-specific TLDs.
host_resolver()->AllowDirectLookup("accounts.google.*");
InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
}
void LiveTest::SetUp() {
// Only run live tests when specified.
auto* cmd_line = base::CommandLine::ForCurrentProcess();
if (!cmd_line->HasSwitch(kRunLiveTestFlag)) {
LOG(INFO) << "This test should get skipped.";
skip_test_ = true;
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();
}
void LiveTest::TearDown() {
// This test was skipped, no need to tear down.
if (skip_test_)
return;
InProcessBrowserTest::TearDown();
}
void LiveTest::PostRunTestOnMainThread() {
// This test was skipped. Running PostRunTestOnMainThread can cause
// TIMED_OUT on Win7.
if (skip_test_)
return;
InProcessBrowserTest::PostRunTestOnMainThread();
}
} // namespace test
} // namespace signin
|