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

Unified Diff: chrome/browser/local_discovery/privet_http_unittest.cc

Issue 59033010: Initial support for /privet/printer/createjob (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e2fce0415a857f5b9bdcf7c657ac5a13f4f8d564..4d2b443665da4b48eaaa44c21f37a8e935ef5192 100644
--- a/chrome/browser/local_discovery/privet_http_unittest.cc
+++ b/chrome/browser/local_discovery/privet_http_unittest.cc
@@ -73,6 +73,33 @@ const char kSampleInfoResponseRegistered[] = "{"
" ]"
"}";
+const char kSampleInfoResponseWithCreatejob[] = "{"
+ " \"version\": \"1.0\","
+ " \"name\": \"Common printer\","
+ " \"description\": \"Printer connected through Chrome connector\","
+ " \"url\": \"https://www.google.com/cloudprint\","
+ " \"type\": ["
+ " \"printer\""
+ " ],"
+ " \"id\": \"\","
+ " \"device_state\": \"idle\","
+ " \"connection_state\": \"online\","
+ " \"manufacturer\": \"Google\","
+ " \"model\": \"Google Chrome\","
+ " \"serial_number\": \"1111-22222-33333-4444\","
+ " \"firmware\": \"24.0.1312.52\","
+ " \"uptime\": 600,"
+ " \"setup_url\": \"http://support.google.com/\","
+ " \"support_url\": \"http://support.google.com/cloudprint/?hl=en\","
+ " \"update_url\": \"http://support.google.com/cloudprint/?hl=en\","
+ " \"x-privet-token\": \"SampleTokenForTesting\","
+ " \"api\": ["
+ " \"/privet/accesstoken\","
+ " \"/privet/capabilities\","
+ " \"/privet/printer/createjob\","
+ " \"/privet/printer/submitdoc\","
+ " ]"
+ "}";
const char kSampleRegisterStartResponse[] = "{"
"\"user\": \"example@google.com\","
@@ -135,6 +162,8 @@ const char kSampleCapabilitiesResponsePWGOnly[] = "{"
"}"
"}";
+const char kSampleCreatejobResponse[] = "{ \"job_id\": \"1234\" }";
+
class MockTestURLFetcherFactoryDelegate
: public net::TestURLFetcher::DelegateForTests {
public:
@@ -790,6 +819,40 @@ TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
kSampleLocalPrintResponse));
};
+TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) {
+ local_print_operation_->SetUsername("sample@gmail.com");
+ local_print_operation_->SetJobname("Sample job name");
+ local_print_operation_->SetTicket("Sample print ticket");
+ local_print_operation_->Start();
+
+ EXPECT_TRUE(SuccessfulResponseToURL(
+ GURL("http://10.0.0.8:6006/privet/info"),
+ kSampleInfoResponseWithCreatejob));
+
+ EXPECT_CALL(local_print_delegate_, OnPrivetPrintingRequestPDFInternal());
+
+ EXPECT_TRUE(SuccessfulResponseToURL(
+ GURL("http://10.0.0.8:6006/privet/capabilities"),
+ kSampleCapabilitiesResponse));
+
+ local_print_operation_->SendData("Sample print data");
+
+ EXPECT_TRUE(SuccessfulResponseToURLAndData(
+ GURL("http://10.0.0.8:6006/privet/printer/createjob"),
+ "Sample print ticket",
+ kSampleCreatejobResponse));
+
+ EXPECT_CALL(local_print_delegate_, OnPrivetPrintingDoneInternal());
+
+ // TODO(noamsml): Is encoding spaces as pluses standard?
+ EXPECT_TRUE(SuccessfulResponseToURLAndData(
+ GURL("http://10.0.0.8:6006/privet/printer/submitdoc?"
+ "user=sample%40gmail.com&jobname=Sample+job+name&job_id=1234"),
+ "Sample print data",
+ kSampleLocalPrintResponse));
+};
+
+
} // namespace
} // namespace local_discovery
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698