| 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" | 14 #include "chromeos/login/user_names.h" |
| 15 #include "components/user_manager/user_manager.h" | 15 #include "components/user_manager/user_manager.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace drive { | 18 namespace drive { |
| 19 | 19 |
| 20 class DriveNotificationManagerFactoryLoginScreenBrowserTest | 20 class DriveNotificationManagerFactoryLoginScreenBrowserTest |
| 21 : public InProcessBrowserTest { | 21 : public InProcessBrowserTest { |
| 22 protected: | 22 protected: |
| 23 virtual void SetUpCommandLine(base::CommandLine* command_line) override { | 23 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 24 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 24 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 25 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 25 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 26 } | 26 } |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 // Verify that no DriveNotificationManager is instantiated for the sign-in | 29 // Verify that no DriveNotificationManager is instantiated for the sign-in |
| 30 // profile on the login screen. | 30 // profile on the login screen. |
| 31 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryLoginScreenBrowserTest, | 31 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryLoginScreenBrowserTest, |
| 32 NoDriveNotificationManager) { | 32 NoDriveNotificationManager) { |
| 33 Profile* signin_profile = | 33 Profile* signin_profile = |
| 34 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); | 34 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); |
| 35 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( | 35 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( |
| 36 signin_profile)); | 36 signin_profile)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 class DriveNotificationManagerFactoryGuestBrowserTest | 39 class DriveNotificationManagerFactoryGuestBrowserTest |
| 40 : public InProcessBrowserTest { | 40 : public InProcessBrowserTest { |
| 41 protected: | 41 protected: |
| 42 virtual void SetUpCommandLine(base::CommandLine* command_line) override { | 42 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 43 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 43 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
| 44 command_line->AppendSwitch(::switches::kIncognito); | 44 command_line->AppendSwitch(::switches::kIncognito); |
| 45 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 45 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
| 46 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | 46 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
| 47 chromeos::login::kGuestUserName); | 47 chromeos::login::kGuestUserName); |
| 48 } | 48 } |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // Verify that no DriveNotificationManager is instantiated for the sign-in | 51 // Verify that no DriveNotificationManager is instantiated for the sign-in |
| 52 // profile or the guest profile while a guest session is in progress. | 52 // profile or the guest profile while a guest session is in progress. |
| 53 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest, | 53 IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest, |
| 54 NoDriveNotificationManager) { | 54 NoDriveNotificationManager) { |
| 55 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 55 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 56 EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); | 56 EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); |
| 57 Profile* guest_profile = | 57 Profile* guest_profile = |
| 58 chromeos::ProfileHelper::Get() | 58 chromeos::ProfileHelper::Get() |
| 59 ->GetProfileByUserUnsafe(user_manager->GetActiveUser()) | 59 ->GetProfileByUserUnsafe(user_manager->GetActiveUser()) |
| 60 ->GetOriginalProfile(); | 60 ->GetOriginalProfile(); |
| 61 Profile* signin_profile = | 61 Profile* signin_profile = |
| 62 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); | 62 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); |
| 63 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( | 63 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( |
| 64 guest_profile)); | 64 guest_profile)); |
| 65 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( | 65 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( |
| 66 signin_profile)); | 66 signin_profile)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace drive | 69 } // namespace drive |
| OLD | NEW |