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

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

Issue 552703002: Fix compilation on Windows with enable_printing=2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mon Sep 8 17:26:04 PDT 2014 Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
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 e19bf1a17196e843a5e632fb211edd45883e518c..94c9bc7ad0db18f4cd8aa1154af4d6f8730afea0 100644
--- a/chrome/browser/local_discovery/privet_http_unittest.cc
+++ b/chrome/browser/local_discovery/privet_http_unittest.cc
@@ -15,6 +15,10 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#if defined(ENABLE_FULL_PRINTING)
+#include "chrome/browser/local_discovery/pwg_raster_converter.h"
+#endif // ENABLE_FULL_PRINTING
+
using testing::StrictMock;
using testing::NiceMock;
@@ -76,34 +80,6 @@ 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\","
"\"action\": \"start\""
@@ -138,14 +114,6 @@ const char kSampleRegisterCancelResponse[] = "{"
"\"action\": \"cancel\""
"}";
-const char kSampleLocalPrintResponse[] = "{"
- "\"job_id\": \"123\","
- "\"expires_in\": 500,"
- "\"job_type\": \"application/pdf\","
- "\"job_size\": 16,"
- "\"job_name\": \"Sample job name\","
- "}";
-
const char kSampleCapabilitiesResponse[] = "{"
"\"version\" : \"1.0\","
"\"printer\" : {"
@@ -156,20 +124,47 @@ const char kSampleCapabilitiesResponse[] = "{"
"}"
"}";
-const char kSampleCapabilitiesResponsePWGOnly[] = "{"
- "\"version\" : \"1.0\","
- "\"printer\" : {"
- " \"supported_content_type\" : ["
- " { \"content_type\" : \"image/pwg-raster\" }"
- " ]"
- "}"
+#if defined(ENABLE_FULL_PRINTING)
+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 kSampleCapabilitiesResponseWithAnyMimetype[] = "{"
+const char kSampleLocalPrintResponse[] = "{"
+ "\"job_id\": \"123\","
+ "\"expires_in\": 500,"
+ "\"job_type\": \"application/pdf\","
+ "\"job_size\": 16,"
+ "\"job_name\": \"Sample job name\","
+ "}";
+
+const char kSampleCapabilitiesResponsePWGOnly[] = "{"
"\"version\" : \"1.0\","
"\"printer\" : {"
" \"supported_content_type\" : ["
- " { \"content_type\" : \"*/*\" },"
" { \"content_type\" : \"image/pwg-raster\" }"
" ]"
"}"
@@ -186,6 +181,16 @@ const char kSampleInvalidDocumentTypeResponse[] = "{"
const char kSampleCreatejobResponse[] = "{ \"job_id\": \"1234\" }";
+const char kSampleCapabilitiesResponseWithAnyMimetype[] = "{"
+ "\"version\" : \"1.0\","
+ "\"printer\" : {"
+ " \"supported_content_type\" : ["
+ " { \"content_type\" : \"*/*\" },"
+ " { \"content_type\" : \"image/pwg-raster\" }"
+ " ]"
+ "}"
+ "}";
+
const char kSampleCJT[] = "{ \"version\" : \"1.0\" }";
const char kSampleCapabilitiesResponsePWGSettings[] =
@@ -207,6 +212,7 @@ const char kSampleCJTDuplex[] =
"\"version\" : \"1.0\","
"\"print\": { \"duplex\": {\"type\": \"SHORT_EDGE\"} }"
"}";
+#endif // ENABLE_FULL_PRINTING
// Return the representation of the given JSON that would be outputted by
// JSONWriter. This ensures the same JSON values are represented by the same
@@ -429,35 +435,6 @@ class MockLocalPrintDelegate : public PrivetLocalPrintOperation::Delegate {
MOCK_METHOD1(OnPrivetPrintingErrorInternal, void(int http_code));
};
-// A note on PWG raster conversion: The PWG raster converter used simply
-// converts strings to file paths based on them by appending "test.pdf", since
-// it's easier to test that way. Instead of using a mock, we simply check if the
-// request is uploading a file that is based on this pattern.
-class FakePWGRasterConverter : public PWGRasterConverter {
- public:
- FakePWGRasterConverter() {
- }
-
- virtual ~FakePWGRasterConverter() {
- }
-
- virtual void Start(base::RefCountedMemory* data,
- const printing::PdfRenderSettings& conversion_settings,
- const printing::PwgRasterSettings& bitmap_settings,
- const ResultCallback& callback) OVERRIDE {
- bitmap_settings_ = bitmap_settings;
- std::string data_str(data->front_as<char>(), data->size());
- callback.Run(true, base::FilePath().AppendASCII(data_str + "test.pdf"));
- }
-
- const printing::PwgRasterSettings& bitmap_settings() {
- return bitmap_settings_;
- }
-
- private:
- printing::PwgRasterSettings bitmap_settings_;
-};
-
class PrivetInfoTest : public PrivetHTTPTest {
public:
PrivetInfoTest() {}
@@ -489,7 +466,7 @@ TEST_F(PrivetInfoTest, SuccessfulInfo) {
EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal());
fetcher->delegate()->OnURLFetchComplete(fetcher);
-};
+}
TEST_F(PrivetInfoTest, InfoFailureHTTP) {
info_operation_->Start();
@@ -502,7 +479,7 @@ TEST_F(PrivetInfoTest, InfoFailureHTTP) {
EXPECT_CALL(info_callback_, OnPrivetJSONDoneInternal());
fetcher->delegate()->OnURLFetchComplete(fetcher);
-};
+}
class PrivetRegisterTest : public PrivetHTTPTest {
public:
@@ -726,7 +703,7 @@ TEST_F(PrivetCapabilitiesTest, SuccessfulCapabilities) {
std::string version;
EXPECT_TRUE(capabilities_callback_.value()->GetString("version", &version));
EXPECT_EQ("1.0", version);
-};
+}
TEST_F(PrivetCapabilitiesTest, CacheToken) {
capabilities_operation_->Start();
@@ -751,7 +728,7 @@ TEST_F(PrivetCapabilitiesTest, CacheToken) {
EXPECT_TRUE(SuccessfulResponseToURL(
GURL("http://10.0.0.8:6006/privet/capabilities"),
kSampleCapabilitiesResponse));
-};
+}
TEST_F(PrivetCapabilitiesTest, BadToken) {
capabilities_operation_->Start();
@@ -773,6 +750,36 @@ TEST_F(PrivetCapabilitiesTest, BadToken) {
EXPECT_TRUE(SuccessfulResponseToURL(
GURL("http://10.0.0.8:6006/privet/capabilities"),
kSampleCapabilitiesResponse));
+}
+
+#if defined(ENABLE_FULL_PRINTING)
+// A note on PWG raster conversion: The PWG raster converter used simply
+// converts strings to file paths based on them by appending "test.pdf", since
+// it's easier to test that way. Instead of using a mock, we simply check if the
+// request is uploading a file that is based on this pattern.
+class FakePWGRasterConverter : public PWGRasterConverter {
+ public:
+ FakePWGRasterConverter() {
+ }
+
+ virtual ~FakePWGRasterConverter() {
+ }
+
+ virtual void Start(base::RefCountedMemory* data,
+ const printing::PdfRenderSettings& conversion_settings,
+ const printing::PwgRasterSettings& bitmap_settings,
+ const ResultCallback& callback) OVERRIDE {
+ bitmap_settings_ = bitmap_settings;
+ std::string data_str(data->front_as<char>(), data->size());
+ callback.Run(true, base::FilePath().AppendASCII(data_str + "test.pdf"));
+ }
+
+ const printing::PwgRasterSettings& bitmap_settings() {
+ return bitmap_settings_;
+ }
+
+ private:
+ printing::PwgRasterSettings bitmap_settings_;
};
class PrivetLocalPrintTest : public PrivetHTTPTest {
@@ -832,7 +839,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrint) {
"job_name=Sample+job+name"),
"Sample print data",
kSampleLocalPrintResponse));
-};
+}
TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -859,7 +866,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithAnyMimetype) {
"job_name=Sample+job+name"),
"Sample print data",
kSampleLocalPrintResponse));
-};
+}
TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -890,7 +897,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrint) {
pwg_converter_->bitmap_settings().odd_page_transform);
EXPECT_FALSE(pwg_converter_->bitmap_settings().rotate_all_pages);
EXPECT_FALSE(pwg_converter_->bitmap_settings().reverse_page_order);
-};
+}
TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrintDuplex) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -927,7 +934,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulPWGLocalPrintDuplex) {
pwg_converter_->bitmap_settings().odd_page_transform);
EXPECT_FALSE(pwg_converter_->bitmap_settings().rotate_all_pages);
EXPECT_TRUE(pwg_converter_->bitmap_settings().reverse_page_order);
-};
+}
TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -959,7 +966,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithCreatejob) {
"job_name=Sample+job+name&job_id=1234"),
"Sample print data",
kSampleLocalPrintResponse));
-};
+}
TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithOverlongName) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -993,7 +1000,7 @@ TEST_F(PrivetLocalPrintTest, SuccessfulLocalPrintWithOverlongName) {
"%3A123456789%3A123456789%3A&job_id=1234"),
"Sample print data",
kSampleLocalPrintResponse));
-};
+}
TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -1032,7 +1039,7 @@ TEST_F(PrivetLocalPrintTest, PDFPrintInvalidDocumentTypeRetry) {
"job_name=Sample+job+name&job_id=1234"),
base::FilePath(FILE_PATH_LITERAL("sample/path/test.pdf")),
kSampleLocalPrintResponse));
-};
+}
TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) {
local_print_operation_->SetUsername("sample@gmail.com");
@@ -1067,8 +1074,8 @@ TEST_F(PrivetLocalPrintTest, LocalPrintRetryOnInvalidJobID) {
EXPECT_TRUE(SuccessfulResponseToURL(
GURL("http://10.0.0.8:6006/privet/printer/createjob"),
kSampleCreatejobResponse));
-};
-
+}
+#endif // ENABLE_FULL_PRINTING
} // namespace
« no previous file with comments | « chrome/browser/local_discovery/privet_http_impl.cc ('k') | chrome/browser/metrics/chrome_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698