Chromium Code Reviews| Index: chromeos/attestation/attestation_flow_unittest.cc |
| diff --git a/chromeos/attestation/attestation_flow_unittest.cc b/chromeos/attestation/attestation_flow_unittest.cc |
| index 51410e2809fef985413a7e07fb5a91708cbf56d9..7be805f317de370207efd8cb6d1769ccbb3d2087 100644 |
| --- a/chromeos/attestation/attestation_flow_unittest.cc |
| +++ b/chromeos/attestation/attestation_flow_unittest.cc |
| @@ -3,6 +3,7 @@ |
| // found in the LICENSE file. |
| #include "base/bind.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/run_loop.h" |
| #include "chromeos/attestation/mock_attestation_flow.h" |
| #include "chromeos/cryptohome/mock_async_method_caller.h" |
| @@ -68,9 +69,9 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
| .Times(1) |
| .InSequence(flow_order); |
| - StrictMock<MockServerProxy> proxy; |
| - proxy.DeferToFake(true); |
| - EXPECT_CALL(proxy, SendEnrollRequest( |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
|
Mattias Nissler (ping if slow)
2013/03/27 14:16:34
should declare this immediately as a scoped_ptr.
dkrahn
2013/03/27 21:20:44
Done.
|
| + proxy->DeferToFake(true); |
| + EXPECT_CALL(*proxy, SendEnrollRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, |
| _)).Times(1) |
| .InSequence(flow_order); |
| @@ -86,7 +87,7 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
| .Times(1) |
| .InSequence(flow_order); |
| - EXPECT_CALL(proxy, SendCertificateRequest( |
| + EXPECT_CALL(*proxy, SendCertificateRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, |
| _)).Times(1) |
| .InSequence(flow_order); |
| @@ -109,7 +110,8 @@ TEST_F(AttestationFlowTest, GetCertificate) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
|
Mattias Nissler (ping if slow)
2013/03/27 14:16:34
And if you have a good reason not to, there's make
dkrahn
2013/03/27 21:20:44
The compiler has trouble with the upcast here beca
|
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -125,7 +127,7 @@ TEST_F(AttestationFlowTest, GetCertificate_NoEK) { |
| .WillRepeatedly(Invoke(DBusCallbackFalse)); |
| // We're not expecting any server calls in this case; StrictMock will verify. |
| - StrictMock<MockServerProxy> proxy; |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| StrictMock<MockObserver> observer; |
| EXPECT_CALL(observer, MockCertificateCallback(false, "")) |
| @@ -134,7 +136,8 @@ TEST_F(AttestationFlowTest, GetCertificate_NoEK) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -149,9 +152,9 @@ TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { |
| EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
| .WillRepeatedly(Invoke(DBusCallbackFalse)); |
| - StrictMock<MockServerProxy> proxy; |
| - proxy.DeferToFake(false); |
| - EXPECT_CALL(proxy, SendEnrollRequest( |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| + proxy->DeferToFake(false); |
| + EXPECT_CALL(*proxy, SendEnrollRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, |
| _)).Times(1); |
| @@ -162,7 +165,8 @@ TEST_F(AttestationFlowTest, GetCertificate_EKRejected) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -182,9 +186,9 @@ TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { |
| EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
| .WillRepeatedly(Invoke(DBusCallbackFalse)); |
| - StrictMock<MockServerProxy> proxy; |
| - proxy.DeferToFake(true); |
| - EXPECT_CALL(proxy, SendEnrollRequest( |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| + proxy->DeferToFake(true); |
| + EXPECT_CALL(*proxy, SendEnrollRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationEnrollRequest, |
| _)).Times(1); |
| @@ -194,7 +198,8 @@ TEST_F(AttestationFlowTest, GetCertificate_FailEnroll) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -215,9 +220,9 @@ TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) { |
| EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
| .WillRepeatedly(Invoke(DBusCallbackTrue)); |
| - StrictMock<MockServerProxy> proxy; |
| - proxy.DeferToFake(true); |
| - EXPECT_CALL(proxy, SendCertificateRequest( |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| + proxy->DeferToFake(true); |
| + EXPECT_CALL(*proxy, SendCertificateRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, |
| _)).Times(1); |
| @@ -229,7 +234,8 @@ TEST_F(AttestationFlowTest, GetOwnerCertificateAlreadyEnrolled) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("attest-ent-machine", mock_callback); |
| Run(); |
| } |
| @@ -245,7 +251,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { |
| .WillRepeatedly(Invoke(DBusCallbackTrue)); |
| // We're not expecting any server calls in this case; StrictMock will verify. |
| - StrictMock<MockServerProxy> proxy; |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| StrictMock<MockObserver> observer; |
| EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
| @@ -253,7 +259,8 @@ TEST_F(AttestationFlowTest, GetCertificate_FailCreateCertRequest) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -268,9 +275,9 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { |
| EXPECT_CALL(client, TpmAttestationIsEnrolled(_)) |
| .WillRepeatedly(Invoke(DBusCallbackTrue)); |
| - StrictMock<MockServerProxy> proxy; |
| - proxy.DeferToFake(false); |
| - EXPECT_CALL(proxy, SendCertificateRequest( |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| + proxy->DeferToFake(false); |
| + EXPECT_CALL(*proxy, SendCertificateRequest( |
| cryptohome::MockAsyncMethodCaller::kFakeAttestationCertRequest, |
| _)).Times(1); |
| @@ -280,7 +287,8 @@ TEST_F(AttestationFlowTest, GetCertificate_CertRequestRejected) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |
| @@ -294,7 +302,7 @@ TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { |
| .WillRepeatedly(Invoke(DBusCallbackFail)); |
| // We're not expecting any server calls in this case; StrictMock will verify. |
| - StrictMock<MockServerProxy> proxy; |
| + StrictMock<MockServerProxy>* proxy(new StrictMock<MockServerProxy>()); |
| StrictMock<MockObserver> observer; |
| EXPECT_CALL(observer, MockCertificateCallback(false, "")).Times(1); |
| @@ -302,7 +310,8 @@ TEST_F(AttestationFlowTest, GetCertificate_FailIsEnrolled) { |
| &MockObserver::MockCertificateCallback, |
| base::Unretained(&observer)); |
| - AttestationFlow flow(&async_caller, &client, &proxy); |
| + scoped_ptr<ServerProxy> scoped_proxy(proxy); |
| + AttestationFlow flow(&async_caller, &client, scoped_proxy.Pass()); |
| flow.GetCertificate("test", mock_callback); |
| Run(); |
| } |