Commit 78ad1e67 authored by Max Morin's avatar Max Morin Committed by Commit Bot

Revert "Migrate Arc unit tests to IdentityManager"

This reverts commit 1e3550d5.

Reason for revert: Failing tests, see crbug.com/837201

Original change's description:
> Migrate Arc unit tests to IdentityManager
> 
> identity::IdentityManager is the new API that replaces SigninManager[Base].
> 
> This includes ArcTermsOfServiceDefaultNegotiatorTest and ArcSupportHostTest.
> 
> Bug: 825190, 731023
> Change-Id: I316c90c6d278e52d723468d63bc21cd288b2642b
> Reviewed-on: https://chromium-review.googlesource.com/1025898
> Reviewed-by: Yusuke Sato <yusukes@chromium.org>
> Commit-Queue: Marc Treib <treib@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#553949}

TBR=yusukes@chromium.org,treib@chromium.org

Change-Id: Iba9649631ec8633c0b89b867a60e89d3d63a01ad
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 825190, 731023, 837201
Reviewed-on: https://chromium-review.googlesource.com/1030150Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Commit-Queue: Max Morin <maxmorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553979}
parent e54d8762
...@@ -10,16 +10,14 @@ ...@@ -10,16 +10,14 @@
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h" #include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/consent_auditor/consent_auditor_test_utils.h" #include "chrome/browser/consent_auditor/consent_auditor_test_utils.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/consent_auditor/fake_consent_auditor.h" #include "components/consent_auditor/fake_consent_auditor.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "services/identity/public/cpp/identity_test_utils.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -74,10 +72,7 @@ class ArcSupportHostTest : public BrowserWithTestWindowTest { ...@@ -74,10 +72,7 @@ class ArcSupportHostTest : public BrowserWithTestWindowTest {
BrowserWithTestWindowTest::SetUp(); BrowserWithTestWindowTest::SetUp();
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>( user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::make_unique<chromeos::FakeChromeUserManager>()); std::make_unique<chromeos::FakeChromeUserManager>());
identity::MakePrimaryAccountAvailable( signin_manager()->SignIn("testing_account_id");
SigninManagerFactory::GetForProfile(profile()),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()),
IdentityManagerFactory::GetForProfile(profile()), "test@account.com");
support_host_ = std::make_unique<ArcSupportHost>(profile()); support_host_ = std::make_unique<ArcSupportHost>(profile());
fake_arc_support_ = std::make_unique<FakeArcSupport>(support_host_.get()); fake_arc_support_ = std::make_unique<FakeArcSupport>(support_host_.get());
...@@ -128,9 +123,15 @@ class ArcSupportHostTest : public BrowserWithTestWindowTest { ...@@ -128,9 +123,15 @@ class ArcSupportHostTest : public BrowserWithTestWindowTest {
ConsentAuditorFactory::GetForProfile(profile())); ConsentAuditorFactory::GetForProfile(profile()));
} }
FakeSigninManagerBase* signin_manager() {
return static_cast<FakeSigninManagerBase*>(
SigninManagerFactory::GetForProfile(profile()));
}
// BrowserWithTestWindowTest: // BrowserWithTestWindowTest:
TestingProfile::TestingFactories GetTestingFactories() override { TestingProfile::TestingFactories GetTestingFactories() override {
return {{ConsentAuditorFactory::GetInstance(), BuildFakeConsentAuditor}}; return {{SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase},
{ConsentAuditorFactory::GetInstance(), BuildFakeConsentAuditor}};
} }
private: private:
......
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h" #include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/consent_auditor/consent_auditor_test_utils.h" #include "chrome/browser/consent_auditor/consent_auditor_test_utils.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
...@@ -26,11 +25,10 @@ ...@@ -26,11 +25,10 @@
#include "components/arc/arc_prefs.h" #include "components/arc/arc_prefs.h"
#include "components/consent_auditor/fake_consent_auditor.h" #include "components/consent_auditor/fake_consent_auditor.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_manager/scoped_user_manager.h" #include "components/user_manager/scoped_user_manager.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "services/identity/public/cpp/identity_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace arc { namespace arc {
...@@ -45,10 +43,7 @@ class ArcTermsOfServiceDefaultNegotiatorTest ...@@ -45,10 +43,7 @@ class ArcTermsOfServiceDefaultNegotiatorTest
BrowserWithTestWindowTest::SetUp(); BrowserWithTestWindowTest::SetUp();
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>( user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::make_unique<chromeos::FakeChromeUserManager>()); std::make_unique<chromeos::FakeChromeUserManager>());
identity::MakePrimaryAccountAvailable( signin_manager()->SignIn("testing_account_id");
SigninManagerFactory::GetForProfile(profile()),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()),
IdentityManagerFactory::GetForProfile(profile()), "test@account.com");
support_host_ = std::make_unique<ArcSupportHost>(profile()); support_host_ = std::make_unique<ArcSupportHost>(profile());
fake_arc_support_ = std::make_unique<FakeArcSupport>(support_host_.get()); fake_arc_support_ = std::make_unique<FakeArcSupport>(support_host_.get());
...@@ -74,15 +69,15 @@ class ArcTermsOfServiceDefaultNegotiatorTest ...@@ -74,15 +69,15 @@ class ArcTermsOfServiceDefaultNegotiatorTest
ConsentAuditorFactory::GetForProfile(profile())); ConsentAuditorFactory::GetForProfile(profile()));
} }
std::string GetAuthenticatedAccountId() { FakeSigninManagerBase* signin_manager() {
return IdentityManagerFactory::GetForProfile(profile()) return static_cast<FakeSigninManagerBase*>(
->GetPrimaryAccountInfo() SigninManagerFactory::GetForProfile(profile()));
.account_id;
} }
// BrowserWithTestWindowTest: // BrowserWithTestWindowTest:
TestingProfile::TestingFactories GetTestingFactories() override { TestingProfile::TestingFactories GetTestingFactories() override {
return {{ConsentAuditorFactory::GetInstance(), BuildFakeConsentAuditor}}; return {{SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase},
{ConsentAuditorFactory::GetInstance(), BuildFakeConsentAuditor}};
} }
private: private:
...@@ -204,7 +199,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, Accept) { ...@@ -204,7 +199,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, Accept) {
consent_auditor::ConsentStatus::GIVEN, consent_auditor::ConsentStatus::GIVEN,
consent_auditor::ConsentStatus::GIVEN, consent_auditor::ConsentStatus::GIVEN,
consent_auditor::ConsentStatus::GIVEN}; consent_auditor::ConsentStatus::GIVEN};
EXPECT_EQ(consent_auditor()->account_id(), GetAuthenticatedAccountId()); EXPECT_EQ(consent_auditor()->account_id(),
signin_manager()->GetAuthenticatedAccountId());
EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids); EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids);
EXPECT_EQ(consent_auditor()->recorded_features(), features); EXPECT_EQ(consent_auditor()->recorded_features(), features);
EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses); EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses);
...@@ -258,7 +254,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, AcceptWithUnchecked) { ...@@ -258,7 +254,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, AcceptWithUnchecked) {
consent_auditor::Feature::PLAY_STORE}; consent_auditor::Feature::PLAY_STORE};
const std::vector<consent_auditor::ConsentStatus> statuses = { const std::vector<consent_auditor::ConsentStatus> statuses = {
consent_auditor::ConsentStatus::GIVEN}; consent_auditor::ConsentStatus::GIVEN};
EXPECT_EQ(consent_auditor()->account_id(), GetAuthenticatedAccountId()); EXPECT_EQ(consent_auditor()->account_id(),
signin_manager()->GetAuthenticatedAccountId());
EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids); EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids);
EXPECT_EQ(consent_auditor()->recorded_features(), features); EXPECT_EQ(consent_auditor()->recorded_features(), features);
EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses); EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses);
...@@ -305,7 +302,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, AcceptWithManagedToS) { ...@@ -305,7 +302,8 @@ TEST_F(ArcTermsOfServiceDefaultNegotiatorTest, AcceptWithManagedToS) {
consent_auditor::Feature::GOOGLE_LOCATION_SERVICE}; consent_auditor::Feature::GOOGLE_LOCATION_SERVICE};
const std::vector<consent_auditor::ConsentStatus> statuses = { const std::vector<consent_auditor::ConsentStatus> statuses = {
consent_auditor::ConsentStatus::GIVEN}; consent_auditor::ConsentStatus::GIVEN};
EXPECT_EQ(consent_auditor()->account_id(), GetAuthenticatedAccountId()); EXPECT_EQ(consent_auditor()->account_id(),
signin_manager()->GetAuthenticatedAccountId());
EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids); EXPECT_EQ(consent_auditor()->recorded_id_vectors(), consent_ids);
EXPECT_EQ(consent_auditor()->recorded_features(), features); EXPECT_EQ(consent_auditor()->recorded_features(), features);
EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses); EXPECT_EQ(consent_auditor()->recorded_statuses(), statuses);
......
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