Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/tests/test_printing.h" | 5 #include "ppapi/tests/test_printing.h" |
| 6 | 6 |
| 7 #include "ppapi/cpp/dev/printing_dev.h" | 7 #include "ppapi/cpp/dev/printing_dev.h" |
| 8 #include "ppapi/cpp/instance.h" | 8 #include "ppapi/cpp/instance.h" |
| 9 #include "ppapi/tests/testing_instance.h" | 9 #include "ppapi/tests/testing_instance.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 bool g_callback_triggered; | 12 bool g_callback_triggered; |
|
yzshen1
2012/10/10 22:49:20
no indent for namespace.
| |
| 13 int32_t g_callback_result; | 13 int32_t g_callback_result; |
| 14 PP_PrintSettings_Dev g_print_settings; | |
| 14 } // namespace | 15 } // namespace |
| 15 | 16 |
| 16 REGISTER_TEST_CASE(Printing); | 17 REGISTER_TEST_CASE(Printing); |
| 17 | 18 |
| 18 class TestPrinting_Dev : public pp::Printing_Dev { | 19 class TestPrinting_Dev : public pp::Printing_Dev { |
| 19 public: | 20 public: |
| 20 explicit TestPrinting_Dev(pp::Instance* instance) : | 21 explicit TestPrinting_Dev(pp::Instance* instance) : |
| 21 pp::Printing_Dev(instance) {} | 22 pp::Printing_Dev(instance) {} |
| 22 virtual ~TestPrinting_Dev() {} | 23 virtual ~TestPrinting_Dev() {} |
| 23 virtual uint32_t QuerySupportedPrintOutputFormats() { return 0; } | 24 virtual uint32_t QuerySupportedPrintOutputFormats() { return 0; } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 46 g_callback_triggered = false; | 47 g_callback_triggered = false; |
| 47 TestPrinting_Dev test_printing(instance_); | 48 TestPrinting_Dev test_printing(instance_); |
| 48 pp::CompletionCallbackWithOutput<PP_PrintSettings_Dev> cb = | 49 pp::CompletionCallbackWithOutput<PP_PrintSettings_Dev> cb = |
| 49 callback_factory_.NewCallbackWithOutput(&TestPrinting::Callback); | 50 callback_factory_.NewCallbackWithOutput(&TestPrinting::Callback); |
| 50 test_printing.GetDefaultPrintSettings(cb); | 51 test_printing.GetDefaultPrintSettings(cb); |
| 51 nested_event_.Wait(); | 52 nested_event_.Wait(); |
| 52 | 53 |
| 53 ASSERT_EQ(PP_OK, g_callback_result); | 54 ASSERT_EQ(PP_OK, g_callback_result); |
| 54 ASSERT_TRUE(g_callback_triggered); | 55 ASSERT_TRUE(g_callback_triggered); |
| 55 | 56 |
| 57 // Sanity check the |printable_area|, |content_area| and |paper_size| members. | |
| 58 // It is possible these values are outside these ranges but it shouldn't | |
| 59 // happen in practice and probably means there is an error in computing | |
| 60 // the default print settings. These values are in points. | |
| 61 ASSERT_TRUE(g_print_settings.printable_area.point.x < 200); | |
| 62 ASSERT_TRUE(g_print_settings.printable_area.point.y < 200); | |
| 63 ASSERT_TRUE(g_print_settings.printable_area.size.width < 2000); | |
| 64 ASSERT_TRUE(g_print_settings.printable_area.size.height < 2000); | |
| 65 | |
| 66 ASSERT_TRUE(g_print_settings.content_area.point.x < 200); | |
| 67 ASSERT_TRUE(g_print_settings.content_area.point.y < 200); | |
| 68 ASSERT_TRUE(g_print_settings.content_area.size.width < 2000); | |
| 69 ASSERT_TRUE(g_print_settings.content_area.size.height< 2000); | |
| 70 | |
| 71 ASSERT_TRUE(g_print_settings.paper_size.width < 2000); | |
| 72 ASSERT_TRUE(g_print_settings.paper_size.height < 2000); | |
| 73 | |
| 56 PASS(); | 74 PASS(); |
| 57 } | 75 } |
| 58 | 76 |
| 59 void TestPrinting::Callback(int32_t result, | 77 void TestPrinting::Callback(int32_t result, |
| 60 PP_PrintSettings_Dev& /* unused */) { | 78 PP_PrintSettings_Dev& print_settings) { |
| 61 g_callback_triggered = true; | 79 g_callback_triggered = true; |
| 62 g_callback_result = result; | 80 g_callback_result = result; |
| 81 g_print_settings = print_settings; | |
| 63 nested_event_.Signal(); | 82 nested_event_.Signal(); |
| 64 } | 83 } |
| OLD | NEW |