diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-19 09:36:41 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-19 09:36:41 +0000 |
commit | c6e06465864cace956a85669afe55007b57ea5a0 (patch) | |
tree | 31b4f9b406de0b59787979b94d4a88be878aa61c /chrome/browser/policy/device_token_fetcher_unittest.cc | |
parent | ea55d4577c4cbe7d1b6cafa97514e1bcfe7b5b4b (diff) | |
download | chromium_src-c6e06465864cace956a85669afe55007b57ea5a0.zip chromium_src-c6e06465864cace956a85669afe55007b57ea5a0.tar.gz chromium_src-c6e06465864cace956a85669afe55007b57ea5a0.tar.bz2 |
Move DeviceManagementPolicyProvider into the profile.
Previously, we used only one provider, which would break in situations where there are two profiles (which ChromeOS already does), because it would apply the policy to both profiles and not only the logged in one. For this to work properly, we also need to pass the relevant TokenService instance the DeviceTokenFetcher, so the fetcher can decide whether the token is relevant to it by checking whether the TokenService that sent it is the one associated with the right profile.
BUG=63608
TEST=existing unit tests succeed
Review URL: http://codereview.chromium.org/5174006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/device_token_fetcher_unittest.cc')
-rw-r--r-- | chrome/browser/policy/device_token_fetcher_unittest.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/chrome/browser/policy/device_token_fetcher_unittest.cc b/chrome/browser/policy/device_token_fetcher_unittest.cc index ea1e41d..7546286 100644 --- a/chrome/browser/policy/device_token_fetcher_unittest.cc +++ b/chrome/browser/policy/device_token_fetcher_unittest.cc @@ -11,13 +11,15 @@ #include "chrome/browser/net/gaia/token_service.h" #include "chrome/browser/policy/device_token_fetcher.h" #include "chrome/browser/policy/mock_device_management_backend.h" +#include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/common/notification_service.h" -#include "chrome/test/device_management_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace policy { +const char kTestToken[] = "device_token_fetcher_test_auth_token"; + using testing::_; using testing::Mock; @@ -46,19 +48,24 @@ class DeviceTokenFetcherTest : public testing::Test { } virtual void TearDown() { + backend_.reset(); + token_service_.reset(); loop_.RunAllPending(); } void SimulateSuccessfulLoginAndRunPending() { loop_.RunAllPending(); - SimulateSuccessfulLogin(); + token_service_->IssueAuthTokenForTest( + GaiaConstants::kDeviceManagementService, kTestToken); loop_.RunAllPending(); } DeviceTokenFetcher* NewTestFetcher(const FilePath& token_dir) { + token_service_.reset(new TokenService); backend_.reset(new MockDeviceManagementBackend()); return new DeviceTokenFetcher( backend_.get(), + token_service_.get(), token_dir.Append(FILE_PATH_LITERAL("test-token-file.txt"))); } @@ -72,6 +79,7 @@ class DeviceTokenFetcherTest : public testing::Test { } MessageLoop loop_; + scoped_ptr<TokenService> token_service_; scoped_ptr<MockDeviceManagementBackend> backend_; ScopedTempDir temp_user_data_dir_; scoped_refptr<DeviceTokenFetcher> fetcher_; @@ -101,7 +109,7 @@ TEST_F(DeviceTokenFetcherTest, StoreAndLoad) { FilePath token_path; GetDeviceTokenPath(fetcher_, &token_path); scoped_refptr<DeviceTokenFetcher> fetcher2( - new DeviceTokenFetcher(backend_.get(), token_path)); + new DeviceTokenFetcher(backend_.get(), token_service_.get(), token_path)); fetcher2->StartFetching(); loop_.RunAllPending(); ASSERT_EQ(device_id, fetcher2->GetDeviceID()); |