OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/chromeos/settings/device_oauth2_token_service.h" | 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "chrome/test/base/scoped_testing_local_state.h" | 9 #include "chrome/test/base/scoped_testing_local_state.h" |
10 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 scoped_testing_local_state_(TestingBrowserProcess::GetGlobal()) {} | 30 scoped_testing_local_state_(TestingBrowserProcess::GetGlobal()) {} |
31 virtual ~DeviceOAuth2TokenServiceTest() {} | 31 virtual ~DeviceOAuth2TokenServiceTest() {} |
32 | 32 |
33 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
34 } | 34 } |
35 | 35 |
36 virtual void TearDown() OVERRIDE { | 36 virtual void TearDown() OVERRIDE { |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 MessageLoop message_loop_; | 40 base::MessageLoop message_loop_; |
41 content::TestBrowserThread ui_thread_; | 41 content::TestBrowserThread ui_thread_; |
42 ScopedTestingLocalState scoped_testing_local_state_; | 42 ScopedTestingLocalState scoped_testing_local_state_; |
43 }; | 43 }; |
44 | 44 |
45 TEST_F(DeviceOAuth2TokenServiceTest, SaveEncryptedToken) { | 45 TEST_F(DeviceOAuth2TokenServiceTest, SaveEncryptedToken) { |
46 StrictMock<MockCryptohomeLibrary> mock_cryptohome_library; | 46 StrictMock<MockCryptohomeLibrary> mock_cryptohome_library; |
47 CryptohomeLibrary::SetForTest(&mock_cryptohome_library); | 47 CryptohomeLibrary::SetForTest(&mock_cryptohome_library); |
48 | 48 |
49 EXPECT_CALL(mock_cryptohome_library, DecryptWithSystemSalt(StrEq(""))) | 49 EXPECT_CALL(mock_cryptohome_library, DecryptWithSystemSalt(StrEq(""))) |
50 .Times(1) | 50 .Times(1) |
(...skipping 13 matching lines...) Expand all Loading... |
64 | 64 |
65 ASSERT_EQ("", oauth2_service.GetRefreshToken()); | 65 ASSERT_EQ("", oauth2_service.GetRefreshToken()); |
66 oauth2_service.SetAndSaveRefreshToken("test-token"); | 66 oauth2_service.SetAndSaveRefreshToken("test-token"); |
67 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); | 67 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); |
68 | 68 |
69 // This call won't invoke decrypt again, since the value is cached. | 69 // This call won't invoke decrypt again, since the value is cached. |
70 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); | 70 ASSERT_EQ("test-token", oauth2_service.GetRefreshToken()); |
71 } | 71 } |
72 | 72 |
73 } // namespace chromeos | 73 } // namespace chromeos |
OLD | NEW |