Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/browser/chromeos/login/ownership_service_unittest.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes comments by eroman Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/login/ownership_service.h" 5 #include "chrome/browser/chromeos/login/ownership_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/crypto/rsa_private_key.h"
10 #include "base/file_path.h" 9 #include "base/file_path.h"
11 #include "base/file_util.h" 10 #include "base/file_util.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_temp_dir.h" 13 #include "base/memory/scoped_temp_dir.h"
15 #include "base/nss_util.h" 14 #include "crypto/nss_util.h"
15 #include "crypto/rsa_private_key.h"
16 #include "chrome/browser/chromeos/login/mock_owner_key_utils.h" 16 #include "chrome/browser/chromeos/login/mock_owner_key_utils.h"
17 #include "chrome/browser/chromeos/login/owner_manager_unittest.h" 17 #include "chrome/browser/chromeos/login/owner_manager_unittest.h"
18 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 using ::base::RSAPrivateKey; 22 using ::crypto::RSAPrivateKey;
23 using ::testing::DoAll; 23 using ::testing::DoAll;
24 using ::testing::Eq; 24 using ::testing::Eq;
25 using ::testing::Invoke; 25 using ::testing::Invoke;
26 using ::testing::Return; 26 using ::testing::Return;
27 using ::testing::SetArgumentPointee; 27 using ::testing::SetArgumentPointee;
28 using ::testing::_; 28 using ::testing::_;
29 29
30 30
31 namespace chromeos { 31 namespace chromeos {
32 32
33 class OwnershipServiceTest : public ::testing::Test { 33 class OwnershipServiceTest : public ::testing::Test {
34 public: 34 public:
35 OwnershipServiceTest() 35 OwnershipServiceTest()
36 : message_loop_(MessageLoop::TYPE_UI), 36 : message_loop_(MessageLoop::TYPE_UI),
37 ui_thread_(BrowserThread::UI, &message_loop_), 37 ui_thread_(BrowserThread::UI, &message_loop_),
38 file_thread_(BrowserThread::FILE), 38 file_thread_(BrowserThread::FILE),
39 mock_(new MockKeyUtils), 39 mock_(new MockKeyUtils),
40 injector_(mock_) /* injector_ takes ownership of mock_ */ { 40 injector_(mock_) /* injector_ takes ownership of mock_ */ {
41 } 41 }
42 virtual ~OwnershipServiceTest() {} 42 virtual ~OwnershipServiceTest() {}
43 43
44 virtual void SetUp() { 44 virtual void SetUp() {
45 base::OpenPersistentNSSDB(); // TODO(cmasone): use test DB instead 45 crypto::OpenPersistentNSSDB(); // TODO(cmasone): use test DB instead
46 fake_private_key_.reset(RSAPrivateKey::Create(256)); 46 fake_private_key_.reset(RSAPrivateKey::Create(256));
47 ASSERT_TRUE(fake_private_key_->ExportPublicKey(&fake_public_key_)); 47 ASSERT_TRUE(fake_private_key_->ExportPublicKey(&fake_public_key_));
48 48
49 // Mimic ownership. 49 // Mimic ownership.
50 ASSERT_TRUE(tmpdir_.CreateUniqueTempDir()); 50 ASSERT_TRUE(tmpdir_.CreateUniqueTempDir());
51 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir_.path(), &tmpfile_)); 51 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(tmpdir_.path(), &tmpfile_));
52 52
53 file_thread_.Start(); 53 file_thread_.Start();
54 OwnerKeyUtils::set_factory(&injector_); 54 OwnerKeyUtils::set_factory(&injector_);
55 service_.reset(new OwnershipService); // must happen AFTER set_factory(). 55 service_.reset(new OwnershipService); // must happen AFTER set_factory().
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 .WillOnce(Return(false)) 207 .WillOnce(Return(false))
208 .RetiresOnSaturation(); 208 .RetiresOnSaturation();
209 209
210 MockKeyUser delegate(OwnerManager::OPERATION_FAILED); 210 MockKeyUser delegate(OwnerManager::OPERATION_FAILED);
211 service_->StartVerifyAttempt(data, sig, &delegate); 211 service_->StartVerifyAttempt(data, sig, &delegate);
212 212
213 message_loop_.Run(); 213 message_loop_.Run();
214 } 214 }
215 215
216 } // namespace chromeos 216 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/owner_manager_unittest.cc ('k') | chrome/browser/chromeos/login/parallel_authenticator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698