1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h" 6 7 #include "chrome/test/base/testing_profile.h" 8 #include "content/public/test/browser_task_environment.h" 9 #include "testing/gtest/include/gtest/gtest.h" 10 11 namespace safe_browsing { 12 13 // Check that AdvancedProtectionStatusManagerFactory returns the same object 14 // for both off-the-record profile and regular profile. TEST(AdvancedProtectionStatusManagerFactoryTest,OffTheRecordUseSameService)15TEST(AdvancedProtectionStatusManagerFactoryTest, OffTheRecordUseSameService) { 16 content::BrowserTaskEnvironment task_environment; 17 18 TestingProfile::Builder builder; 19 std::unique_ptr<TestingProfile> testing_profile = builder.Build(); 20 21 // The regular profile and the off-the-record profile must be different. 22 ASSERT_NE(testing_profile.get(), testing_profile->GetPrimaryOTRProfile()); 23 24 EXPECT_EQ(AdvancedProtectionStatusManagerFactory::GetForProfile( 25 testing_profile.get()), 26 AdvancedProtectionStatusManagerFactory::GetForProfile( 27 testing_profile->GetPrimaryOTRProfile())); 28 29 // Two different off-the-record profiles must be different. 30 EXPECT_EQ(AdvancedProtectionStatusManagerFactory::GetForProfile( 31 testing_profile->GetPrimaryOTRProfile()), 32 AdvancedProtectionStatusManagerFactory::GetForProfile( 33 testing_profile->GetOffTheRecordProfile( 34 Profile::OTRProfileID("Test::AdvancedProtection")))); 35 } 36 37 } // namespace safe_browsing 38