| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cloud_print/virtual_driver/posix/printer_driver_util_posix.h" | |
| 6 #include "testing/gtest/include/gtest/gtest.h" | |
| 7 | |
| 8 namespace printer_driver_util { | |
| 9 | |
| 10 void test_helper(const char* input, std::string expected_output) { | |
| 11 std::string test; | |
| 12 GetOptions(input, &test); | |
| 13 EXPECT_EQ(expected_output, test); | |
| 14 } | |
| 15 | |
| 16 TEST(PrintTicketTest, HandlesEmpty) { | |
| 17 test_helper("", "{}"); | |
| 18 } | |
| 19 | |
| 20 TEST(PrintTicketTest, HandlesNull) { | |
| 21 test_helper(NULL, "{}"); | |
| 22 } | |
| 23 | |
| 24 TEST(PrintTicketTest, HandlesOneOption) { | |
| 25 test_helper("Resolution=500", "{\"Resolution\":\"500\"}"); | |
| 26 } | |
| 27 | |
| 28 TEST(PrintTicketTest, HandlesMutipleOptions) { | |
| 29 test_helper("Resolution=500 DPI=1100", | |
| 30 "{\"DPI\":\"1100\",\"Resolution\":\"500\"}"); | |
| 31 } | |
| 32 | |
| 33 TEST(PrintTicketTest, HandlesErrorInOptions) { | |
| 34 test_helper("Resolution=500 Foo DPI=1100", | |
| 35 "{\"DPI\":\"1100\",\"Resolution\":\"500\"}"); | |
| 36 } | |
| 37 | |
| 38 TEST(PrintTicketTest, HandlesMutipleSpaces) { | |
| 39 test_helper("Resolution=500 DPI=1100", | |
| 40 "{\"DPI\":\"1100\",\"Resolution\":\"500\"}"); | |
| 41 } | |
| 42 | |
| 43 TEST(PrintTicketTest, HandlesEscapedSpace) { | |
| 44 test_helper("Job\\ Owner=First\\ Last", | |
| 45 "{\"Job Owner\":\"First Last\"}"); | |
| 46 } | |
| 47 | |
| 48 TEST(PrintTicketTest, HandlesMultipleEscapedWords) { | |
| 49 test_helper("Job\\ Owner\\ Name=First\\ Last", | |
| 50 "{\"Job Owner Name\":\"First Last\"}"); | |
| 51 } | |
| 52 | |
| 53 TEST(PrintTicketTest, HandlesMultipleEscapedSpaces) { | |
| 54 test_helper("Job\\ Owner\\ \\ Name=First\\ Last", | |
| 55 "{\"Job Owner Name\":\"First Last\"}"); | |
| 56 } | |
| 57 | |
| 58 TEST(PrintTicketTest, HandlesKeyEndsInEscapedSpace) { | |
| 59 test_helper("Job\\ Owner\\ =First\\ Last", | |
| 60 "{\"Job Owner \":\"First Last\"}"); | |
| 61 } | |
| 62 | |
| 63 TEST(PrintTicketTest, HandlesSlashAtEnd) { | |
| 64 test_helper("Job\\ Owner=First\\ Last\\", | |
| 65 "{\"Job Owner\":\"First Last\\\\\"}"); | |
| 66 } | |
| 67 | |
| 68 | |
| 69 } // namespace printer_driver_util | |
| 70 | |
| 71 int main(int argc, char **argv) { | |
| 72 ::testing::InitGoogleTest(&argc, argv); | |
| 73 return RUN_ALL_TESTS(); | |
| 74 } | |
| 75 | |
| OLD | NEW |