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

Unified Diff: ppapi/tests/test_printing.cc

Issue 10826072: Implement browser side of PPB_Printing resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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
« no previous file with comments | « ppapi/tests/test_printing.h ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_printing.cc
diff --git a/ppapi/tests/test_printing.cc b/ppapi/tests/test_printing.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6a82ebbe242a0805d646895ea713d5d8bb6f6463
--- /dev/null
+++ b/ppapi/tests/test_printing.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/tests/test_printing.h"
+
+#include "ppapi/cpp/dev/printing_dev.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/tests/testing_instance.h"
+
+namespace {
+ bool g_callback_triggered;
+ int32_t g_callback_result;
+} // namespace
+
+REGISTER_TEST_CASE(Printing);
+
+class TestPrinting_Dev : public pp::Printing_Dev {
+ public:
+ explicit TestPrinting_Dev(pp::Instance* instance) :
+ pp::Printing_Dev(instance) {}
+ virtual ~TestPrinting_Dev() {}
+ virtual uint32_t QuerySupportedPrintOutputFormats() { return 0; }
+ virtual int32_t PrintBegin(
+ const PP_PrintSettings_Dev& print_settings) { return 0; }
+ virtual pp::Resource PrintPages(
+ const PP_PrintPageNumberRange_Dev* page_ranges,
+ uint32_t page_range_count) {
+ return pp::Resource();
+ }
+ virtual void PrintEnd() {}
+ virtual bool IsPrintScalingDisabled() { return false; }
+};
+
+TestPrinting::TestPrinting(TestingInstance* instance)
+ : TestCase(instance),
+ nested_event_(instance->pp_instance()) {
+ callback_factory_.Initialize(this);
+}
+
+void TestPrinting::RunTests(const std::string& filter) {
+ RUN_TEST(GetDefaultPrintSettings, filter);
+}
+
+std::string TestPrinting::TestGetDefaultPrintSettings() {
+ g_callback_triggered = false;
+ TestPrinting_Dev test_printing(instance_);
+ pp::CompletionCallbackWithOutput<PP_PrintSettings_Dev> cb =
+ callback_factory_.NewCallbackWithOutput(&TestPrinting::Callback);
+ test_printing.GetDefaultPrintSettings(cb);
+ nested_event_.Wait();
+
+ ASSERT_EQ(PP_OK, g_callback_result);
+ ASSERT_TRUE(g_callback_triggered);
+
+ PASS();
+}
+
+void TestPrinting::Callback(int32_t result,
+ PP_PrintSettings_Dev& /* unused */) {
+ g_callback_triggered = true;
+ g_callback_result = result;
+ nested_event_.Signal();
+}
« no previous file with comments | « ppapi/tests/test_printing.h ('k') | ppapi/thunk/enter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698