1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "crypto/scoped_test_system_nss_key_slot.h"
7 #include "crypto/nss_util.h"
8 #include "crypto/nss_util_internal.h"
9 #include "crypto/scoped_test_nss_db.h"
13 ScopedTestSystemNSSKeySlot::ScopedTestSystemNSSKeySlot(
14 bool simulate_token_loader)
15 : test_db_(new ScopedTestNSSDB) {
16 if (!test_db_->is_open())
19 PrepareSystemSlotForTesting( // IN-TEST
20 ScopedPK11Slot(PK11_ReferenceSlot(test_db_->slot())));
22 if (simulate_token_loader)
23 FinishInitializingTPMTokenAndSystemSlot();
26 ScopedTestSystemNSSKeySlot::~ScopedTestSystemNSSKeySlot() {
27 ResetSystemSlotForTesting(); // IN-TEST
30 bool ScopedTestSystemNSSKeySlot::ConstructedSuccessfully() const {
31 return test_db_->is_open();
34 PK11SlotInfo* ScopedTestSystemNSSKeySlot::slot() const {
35 return test_db_->slot();