// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/drive/drive_system_service.h"

#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"

namespace drive {

class DriveSystemServiceBrowserTest : public InProcessBrowserTest {
};

// Verify DriveSystemService is created during login.
IN_PROC_BROWSER_TEST_F(DriveSystemServiceBrowserTest, CreatedDuringLogin) {
  EXPECT_TRUE(DriveSystemServiceFactory::FindForProfile(browser()->profile()));
}

}  // namespace drive

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chromeos/drive/drive_system_service.h"

#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"

namespace drive {

class DriveSystemServiceBrowserTest : public InProcessBrowserTest {
};

// Verify DriveSystemService is created during login.
IN_PROC_BROWSER_TEST_F(DriveSystemServiceBrowserTest, CreatedDuringLogin) {
  EXPECT_TRUE(DriveSystemServiceFactory::FindForProfile(browser()->profile()));
}


IN_PROC_BROWSER_TEST_F(DriveSystemServiceBrowserTest,
                       DisableDrivePolicyTest) {
  // First make sure the pref is set to its default value which should permit
  // drive.
  browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableDrive, false);

  drive::DriveSystemService* drive_service =
      drive::DriveSystemServiceFactory::GetForProfile(browser()->profile());

  EXPECT_TRUE(drive_service);

  // ...next try to disable drive.
  browser()->profile()->GetPrefs()->SetBoolean(prefs::kDisableDrive, true);

  drive_service =
      drive::DriveSystemServiceFactory::GetForProfile(browser()->profile());

  EXPECT_FALSE(drive_service);
}

}  // namespace drive

Add a test to verify that the DriveDisabled policy prevents Drive access for realz.
Add a test to verify that the DriveDisabled policy prevents Drive access for realz.

BUG=165490
TEST=browser_tests:DriveSystemServiceBrowserTest.DisableDrivePolicyTest


Review URL: https://chromiumcodereview.appspot.com/12226057

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@181482 0039d316-1c4b-4281-b951-d872f2087c98
