| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/drive/drive_notification_manager_factory.h" | 5 #include "chrome/browser/drive/drive_notification_manager_factory.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "chromeos/login/user_names.h" | |
| 15 #include "components/signin/core/account_id/account_id.h" | 14 #include "components/signin/core/account_id/account_id.h" |
| 16 #include "components/user_manager/user_manager.h" | 15 #include "components/user_manager/user_manager.h" |
| 16 #include "components/user_manager/user_names.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace drive { | 19 namespace drive { |
| 20 | 20 |
| 21 class DriveNotificationManagerFactoryLoginScreenBrowserTest | 21 class DriveNotificationManagerFactoryLoginScreenBrowserTest |
| 22 : public InProcessBrowserTest { | 22 : public InProcessBrowserTest { |
| 23 protected: | 23 protected: |
| 24 void SetUpCommandLine(base::CommandLine* command_line) override { | 24 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 25 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 25 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 26 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 26 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 class DriveNotificationManagerFactoryGuestBrowserTest | 40 class DriveNotificationManagerFactoryGuestBrowserTest |
| 41 : public InProcessBrowserTest { | 41 : public InProcessBrowserTest { |
| 42 protected: | 42 protected: |
| 43 void SetUpCommandLine(base::CommandLine* command_line) override { | 43 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 44 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 44 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 45 command_line->AppendSwitch(::switches::kIncognito); | 45 command_line->AppendSwitch(::switches::kIncognito); |
| 46 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 46 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 47 command_line->AppendSwitchASCII( | 47 command_line->AppendSwitchASCII( |
| 48 chromeos::switches::kLoginUser, | 48 chromeos::switches::kLoginUser, |
| 49 chromeos::login::GuestAccountId().GetUserEmail()); | 49 user_manager::chromeos::GuestAccountId().GetUserEmail()); |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 // Verify that no DriveNotificationManager is instantiated for the sign-in | 53 // Verify that no DriveNotificationManager is instantiated for the sign-in |
| 54 // profile or the guest profile while a guest session is in progress. | 54 // profile or the guest profile while a guest session is in progress. |
| 55 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest, | 55 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest, |
| 56 NoDriveNotificationManager) { | 56 NoDriveNotificationManager) { |
| 57 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 57 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 58 EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); | 58 EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); |
| 59 Profile* guest_profile = | 59 Profile* guest_profile = |
| 60 chromeos::ProfileHelper::Get() | 60 chromeos::ProfileHelper::Get() |
| 61 ->GetProfileByUserUnsafe(user_manager->GetActiveUser()) | 61 ->GetProfileByUserUnsafe(user_manager->GetActiveUser()) |
| 62 ->GetOriginalProfile(); | 62 ->GetOriginalProfile(); |
| 63 Profile* signin_profile = | 63 Profile* signin_profile = |
| 64 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); | 64 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); |
| 65 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( | 65 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( |
| 66 guest_profile)); | 66 guest_profile)); |
| 67 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( | 67 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( |
| 68 signin_profile)); | 68 signin_profile)); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace drive | 71 } // namespace drive |
| OLD | NEW |