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

Side by Side Diff: components/autofill/content/browser/wallet/encryption_escrow_client_unittest.cc

Issue 17465003: Fix most tests in //components/autofill/content to not depend on //chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation issue in interactive_ui_tests. Created 7 years, 6 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 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/test/base/testing_profile.h"
7 #include "components/autofill/content/browser/wallet/encryption_escrow_client.h" 6 #include "components/autofill/content/browser/wallet/encryption_escrow_client.h"
8 #include "components/autofill/content/browser/wallet/encryption_escrow_client_ob server.h" 7 #include "components/autofill/content/browser/wallet/encryption_escrow_client_ob server.h"
9 #include "components/autofill/content/browser/wallet/instrument.h" 8 #include "components/autofill/content/browser/wallet/instrument.h"
10 #include "components/autofill/content/browser/wallet/wallet_test_util.h" 9 #include "components/autofill/content/browser/wallet/wallet_test_util.h"
10 #include "content/public/test/test_browser_context.h"
11 #include "content/public/test/test_browser_thread.h" 11 #include "content/public/test/test_browser_thread.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 #include "net/url_request/test_url_fetcher_factory.h" 15 #include "net/url_request/test_url_fetcher_factory.h"
16 #include "net/url_request/url_fetcher_delegate.h" 16 #include "net/url_request/url_fetcher_delegate.h"
17 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 }; 64 };
65 65
66 class EncryptionEscrowClientTest : public testing::Test { 66 class EncryptionEscrowClientTest : public testing::Test {
67 public: 67 public:
68 EncryptionEscrowClientTest() 68 EncryptionEscrowClientTest()
69 : instrument_(GetTestInstrument()), 69 : instrument_(GetTestInstrument()),
70 io_thread_(content::BrowserThread::IO) {} 70 io_thread_(content::BrowserThread::IO) {}
71 71
72 virtual void SetUp() OVERRIDE { 72 virtual void SetUp() OVERRIDE {
73 io_thread_.StartIOThread(); 73 io_thread_.StartIOThread();
74 profile_.CreateRequestContext();
75 encryption_escrow_client_.reset(new TestEncryptionEscrowClient( 74 encryption_escrow_client_.reset(new TestEncryptionEscrowClient(
76 profile_.GetRequestContext(), &observer_)); 75 browser_context_.GetRequestContext(), &observer_));
77 } 76 }
78 77
79 virtual void TearDown() OVERRIDE { 78 virtual void TearDown() OVERRIDE {
80 encryption_escrow_client_.reset(); 79 encryption_escrow_client_.reset();
81 profile_.ResetRequestContext();
82 io_thread_.Stop(); 80 io_thread_.Stop();
83 } 81 }
84 82
85 std::vector<uint8> MakeOneTimePad() { 83 std::vector<uint8> MakeOneTimePad() {
86 std::vector<uint8> one_time_pad; 84 std::vector<uint8> one_time_pad;
87 one_time_pad.push_back(0); 85 one_time_pad.push_back(0);
88 one_time_pad.push_back(1); 86 one_time_pad.push_back(1);
89 one_time_pad.push_back(2); 87 one_time_pad.push_back(2);
90 one_time_pad.push_back(3); 88 one_time_pad.push_back(3);
91 one_time_pad.push_back(4); 89 one_time_pad.push_back(4);
(...skipping 12 matching lines...) Expand all
104 fetcher->delegate()->OnURLFetchComplete(fetcher); 102 fetcher->delegate()->OnURLFetchComplete(fetcher);
105 } 103 }
106 104
107 protected: 105 protected:
108 scoped_ptr<TestEncryptionEscrowClient> encryption_escrow_client_; 106 scoped_ptr<TestEncryptionEscrowClient> encryption_escrow_client_;
109 testing::StrictMock<MockEncryptionEscrowClientObserver> observer_; 107 testing::StrictMock<MockEncryptionEscrowClientObserver> observer_;
110 scoped_ptr<Instrument> instrument_; 108 scoped_ptr<Instrument> instrument_;
111 109
112 110
113 private: 111 private:
114 // The profile's request context must be released on the IO thread.
115 content::TestBrowserThread io_thread_; 112 content::TestBrowserThread io_thread_;
blundell 2013/06/19 15:34:52 Is this still needed?
Jói 2013/06/19 15:38:04 I'm not sure; let me test.
116 TestingProfile profile_; 113 content::TestBrowserContext browser_context_;
117 net::TestURLFetcherFactory factory_; 114 net::TestURLFetcherFactory factory_;
118 }; 115 };
119 116
120 TEST_F(EncryptionEscrowClientTest, NetworkError) { 117 TEST_F(EncryptionEscrowClientTest, NetworkError) {
121 EXPECT_CALL(observer_, OnDidMakeRequest()).Times(1); 118 EXPECT_CALL(observer_, OnDidMakeRequest()).Times(1);
122 EXPECT_CALL(observer_, OnNetworkError()).Times(1); 119 EXPECT_CALL(observer_, OnNetworkError()).Times(1);
123 120
124 encryption_escrow_client_->EscrowInstrumentInformation(*instrument_, 121 encryption_escrow_client_->EscrowInstrumentInformation(*instrument_,
125 "obfuscated_gaia_id"); 122 "obfuscated_gaia_id");
126 VerifyAndFinishRequest(net::HTTP_UNAUTHORIZED, 123 VerifyAndFinishRequest(net::HTTP_UNAUTHORIZED,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 192
196 encryption_escrow_client_->EncryptOneTimePad(MakeOneTimePad()); 193 encryption_escrow_client_->EncryptOneTimePad(MakeOneTimePad());
197 EXPECT_TRUE(encryption_escrow_client_->HasRequestInProgress()); 194 EXPECT_TRUE(encryption_escrow_client_->HasRequestInProgress());
198 195
199 encryption_escrow_client_->CancelRequest(); 196 encryption_escrow_client_->CancelRequest();
200 EXPECT_FALSE(encryption_escrow_client_->HasRequestInProgress()); 197 EXPECT_FALSE(encryption_escrow_client_->HasRequestInProgress());
201 } 198 }
202 199
203 } // namespace wallet 200 } // namespace wallet
204 } // namespace autofill 201 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698