File: parent_access_browsertest_base.cc

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (85 lines) | stat: -rw-r--r-- 3,247 bytes parent folder | download | duplicates (6)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/ash/parent_access/parent_access_browsertest_base.h"

#include <string>

#include "chrome/browser/browser_process.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/webui/ash/parent_access/parent_access_dialog.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"

namespace ash {

ParentAccessBrowserTestBase::ParentAccessBrowserTestBase() = default;
ParentAccessBrowserTestBase::~ParentAccessBrowserTestBase() = default;

void ParentAccessBrowserTestBase::SetUp() {
  logged_in_user_mixin_ = std::make_unique<LoggedInUserMixin>(
      &mixin_host_, /*test_base=*/this, embedded_test_server(), GetLogInType());
  // Setup() must be called after the mixin is instantiated because it is what
  // actually causes the tests to be run.
  MixinBasedInProcessBrowserTest::SetUp();
}

content::WebUI* ParentAccessBrowserTestBase::GetWebUI() {
  return ParentAccessDialog::GetInstance()->GetWebUIForTest();
}

ParentAccessUI* ParentAccessBrowserTestBase::GetParentAccessUI() {
  return static_cast<ParentAccessUI*>(GetWebUI()->GetController());
}

content::WebContents* ParentAccessBrowserTestBase::GetContents() {
  return GetWebUI()->GetWebContents();
}

// InProcessBrowserTest methods
void ParentAccessBrowserTestBase::SetUpOnMainThread() {
  MixinBasedInProcessBrowserTest::SetUpOnMainThread();
  // Login must occur here because it relies on additional setup
  // that takes place after Setup()
  logged_in_user_mixin_->LogInUser();

  // The identity test environment is independent of the logged in user  mixin
  // and is used to configure the OAuth token fetcher for test.
  identity_test_env_ = std::make_unique<signin::IdentityTestEnvironment>();
  identity_test_env_->MakePrimaryAccountAvailable(
      logged_in_user_mixin_->GetAccountId().GetUserEmail(),
      signin::ConsentLevel::kSync);
  // This makes the identity manager return the string "access_token" for the
  // access token.
  identity_test_env_->SetAutomaticIssueOfAccessTokens(true);
  ParentAccessUI::SetUpForTest(identity_test_env_->identity_manager());
}

//  ParentAccessRegularUserBrowserTestBase
ParentAccessRegularUserBrowserTestBase::
    ParentAccessRegularUserBrowserTestBase() = default;
ParentAccessRegularUserBrowserTestBase::
    ~ParentAccessRegularUserBrowserTestBase() = default;

// ParentAccessBrowserTestBase methods
LoggedInUserMixin::LogInType
ParentAccessRegularUserBrowserTestBase::GetLogInType() {
  return LoggedInUserMixin::LogInType::kConsumer;
}

//  ParentAccessChildUserBrowserTestBase
ParentAccessChildUserBrowserTestBase::ParentAccessChildUserBrowserTestBase() =
    default;
ParentAccessChildUserBrowserTestBase::~ParentAccessChildUserBrowserTestBase() =
    default;

// ParentAccessBrowserTestBase methods
LoggedInUserMixin::LogInType
ParentAccessChildUserBrowserTestBase::GetLogInType() {
  return LoggedInUserMixin::LogInType::kChild;
}

}  // namespace ash