Index: chrome/browser/local_discovery/privet_http_unittest.cc |
diff --git a/chrome/browser/local_discovery/privet_http_unittest.cc b/chrome/browser/local_discovery/privet_http_unittest.cc |
index e895545f80a6b533f1518f047eb50aa5b3f38300..31da0d62c0d602afebe18ff19408b294dda17c40 100644 |
--- a/chrome/browser/local_discovery/privet_http_unittest.cc |
+++ b/chrome/browser/local_discovery/privet_http_unittest.cc |
@@ -202,6 +202,8 @@ class MockTestURLFetcherFactoryDelegate |
class PrivetHTTPTest : public ::testing::Test { |
public: |
PrivetHTTPTest() { |
+ PrivetURLFetcher::ResetTokenMapForTests(); |
+ |
request_context_= new net::TestURLRequestContextGetter( |
base::MessageLoopProxy::current()); |
privet_client_.reset(new PrivetHTTPClientImpl( |
@@ -442,37 +444,6 @@ TEST_F(PrivetInfoTest, SuccessfulInfo) { |
EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal()); |
fetcher->delegate()->OnURLFetchComplete(fetcher); |
- |
- std::string name; |
- |
- privet_client_->GetCachedInfo()->GetString("name", &name); |
- EXPECT_EQ("Common printer", name); |
-}; |
- |
-TEST_F(PrivetInfoTest, InfoSaveToken) { |
- info_operation_->Start(); |
- |
- net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0); |
- ASSERT_TRUE(fetcher != NULL); |
- fetcher->SetResponseString(kSampleInfoResponse); |
- fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::SUCCESS, |
- net::OK)); |
- fetcher->set_response_code(200); |
- |
- EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal()); |
- fetcher->delegate()->OnURLFetchComplete(fetcher); |
- |
- info_operation_ = |
- privet_client_->CreateInfoOperation(info_callback_.callback()); |
- info_operation_->Start(); |
- |
- fetcher = fetcher_factory_.GetFetcherByID(0); |
- ASSERT_TRUE(fetcher != NULL); |
- net::HttpRequestHeaders headers; |
- fetcher->GetExtraRequestHeaders(&headers); |
- std::string header_token; |
- ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token)); |
- EXPECT_EQ("SampleTokenForTesting", header_token); |
}; |
TEST_F(PrivetInfoTest, InfoFailureHTTP) { |
@@ -486,7 +457,6 @@ TEST_F(PrivetInfoTest, InfoFailureHTTP) { |
EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal()); |
fetcher->delegate()->OnURLFetchComplete(fetcher); |
- EXPECT_EQ(NULL, privet_client_->GetCachedInfo()); |
}; |
class PrivetRegisterTest : public PrivetHTTPTest { |
@@ -528,15 +498,12 @@ class PrivetRegisterTest : public PrivetHTTPTest { |
}; |
TEST_F(PrivetRegisterTest, RegisterSuccessSimple) { |
- // Start with info request first to populate XSRF token. |
- info_operation_->Start(); |
+ register_operation_->Start(); |
EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/info"), |
kSampleInfoResponse)); |
- register_operation_->Start(); |
- |
EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/register?" |
"action=start&user=example%40google.com"), |
@@ -566,19 +533,6 @@ TEST_F(PrivetRegisterTest, RegisterSuccessSimple) { |
kSampleInfoResponseRegistered)); |
} |
-TEST_F(PrivetRegisterTest, RegisterNoInfoCall) { |
- register_operation_->Start(); |
- |
- EXPECT_TRUE(SuccessfulResponseToURL( |
- GURL("http://10.0.0.8:6006/privet/info"), |
- kSampleInfoResponse)); |
- |
- EXPECT_TRUE(SuccessfulResponseToURL( |
- GURL("http://10.0.0.8:6006/privet/register?" |
- "action=start&user=example%40google.com"), |
- kSampleRegisterStartResponse)); |
-} |
- |
TEST_F(PrivetRegisterTest, RegisterXSRFFailure) { |
register_operation_->Start(); |
@@ -672,15 +626,12 @@ TEST_F(PrivetRegisterTest, InfoFailure) { |
} |
TEST_F(PrivetRegisterTest, RegisterCancel) { |
- // Start with info request first to populate XSRF token. |
- info_operation_->Start(); |
+ register_operation_->Start(); |
EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/info"), |
kSampleInfoResponse)); |
- register_operation_->Start(); |
- |
EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/register?" |
"action=start&user=example%40google.com"), |
@@ -786,6 +737,8 @@ class PrivetLocalPrintTest : public PrivetHTTPTest { |
virtual ~PrivetLocalPrintTest() {} |
virtual void SetUp() OVERRIDE { |
+ PrivetURLFetcher::ResetTokenMapForTests(); |
+ |
local_print_operation_ = privet_client_->CreateLocalPrintOperation( |
&local_print_delegate_); |
@@ -818,6 +771,10 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) { |
kSampleInfoResponse)); |
EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponse)); |
@@ -844,6 +801,10 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) { |
kSampleInfoResponse)); |
EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponseWithAnyMimetype)); |
@@ -870,6 +831,10 @@ TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) { |
kSampleInfoResponse)); |
EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponsePWGOnly)); |
@@ -897,6 +862,10 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) { |
kSampleInfoResponseWithCreatejob)); |
EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponse)); |
@@ -929,6 +898,10 @@ TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) { |
kSampleInfoResponseWithCreatejob)); |
EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponse)); |
@@ -967,6 +940,11 @@ TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) { |
GURL("http://10.0.0.8:6006/privet/info"), |
kSampleInfoResponseWithCreatejob)); |
+ |
+ EXPECT_TRUE(SuccessfulResponseToURL( |
+ GURL("http://10.0.0.8:6006/privet/info"), |
+ kSampleInfoResponse)); |
+ |
EXPECT_TRUE(SuccessfulResponseToURL( |
GURL("http://10.0.0.8:6006/privet/capabilities"), |
kSampleCapabilitiesResponse)); |