drive_notification_manager_factory_browsertest.cc revision cedac228d2dd51db4b79ea1e72c7f249408ee061
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 3// found in the LICENSE file. 4 5#include "chrome/browser/drive/drive_notification_manager_factory.h" 6 7#include "base/command_line.h" 8#include "base/compiler_specific.h" 9#include "chrome/browser/chromeos/login/users/user_manager.h" 10#include "chrome/browser/chromeos/profiles/profile_helper.h" 11#include "chrome/browser/profiles/profile.h" 12#include "chrome/common/chrome_switches.h" 13#include "chrome/test/base/in_process_browser_test.h" 14#include "chromeos/chromeos_switches.h" 15#include "testing/gtest/include/gtest/gtest.h" 16 17namespace drive { 18 19class DriveNotificationManagerFactoryLoginScreenBrowserTest 20 : public InProcessBrowserTest { 21 protected: 22 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 23 command_line->AppendSwitch(chromeos::switches::kLoginManager); 24 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 25 } 26}; 27 28// Verify that no DriveNotificationManager is instantiated for the sign-in 29// profile on the login screen. 30IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryLoginScreenBrowserTest, 31 NoDriveNotificationManager) { 32 Profile* signin_profile = 33 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); 34 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( 35 signin_profile)); 36} 37 38class DriveNotificationManagerFactoryGuestBrowserTest 39 : public InProcessBrowserTest { 40 protected: 41 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 42 command_line->AppendSwitch(chromeos::switches::kGuestSession); 43 command_line->AppendSwitch(::switches::kIncognito); 44 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); 45 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, 46 chromeos::UserManager::kGuestUserName); 47 } 48}; 49 50// Verify that no DriveNotificationManager is instantiated for the sign-in 51// profile or the guest profile while a guest session is in progress. 52IN_PROC_BROWSER_TEST_F(DriveNotificationManagerFactoryGuestBrowserTest, 53 NoDriveNotificationManager) { 54 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); 55 EXPECT_TRUE(user_manager->IsLoggedInAsGuest()); 56 Profile* guest_profile = user_manager->GetProfileByUser( 57 user_manager->GetActiveUser())->GetOriginalProfile(); 58 Profile* signin_profile = 59 chromeos::ProfileHelper::GetSigninProfile()->GetOriginalProfile(); 60 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( 61 guest_profile)); 62 EXPECT_FALSE(DriveNotificationManagerFactory::FindForBrowserContext( 63 signin_profile)); 64} 65 66} // namespace drive 67