| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/printing/print_job.h" | 6 #include "chrome/browser/printing/print_job.h" |
| 7 #include "chrome/browser/printing/print_job_worker.h" | 7 #include "chrome/browser/printing/print_job_worker.h" |
| 8 #include "chrome/common/notification_registrar.h" | 8 #include "chrome/common/notification_registrar.h" |
| 9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
| 10 #include "printing/printed_pages_source.h" | 10 #include "printing/printed_pages_source.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class TestPrintJobWorker : public printing::PrintJobWorker { | 26 class TestPrintJobWorker : public printing::PrintJobWorker { |
| 27 public: | 27 public: |
| 28 explicit TestPrintJobWorker(printing::PrintJobWorkerOwner* owner) | 28 explicit TestPrintJobWorker(printing::PrintJobWorkerOwner* owner) |
| 29 : printing::PrintJobWorker(owner) { | 29 : printing::PrintJobWorker(owner) { |
| 30 } | 30 } |
| 31 friend class TestOwner; | 31 friend class TestOwner; |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class TestOwner : public printing::PrintJobWorkerOwner { | 34 class TestOwner : public printing::PrintJobWorkerOwner { |
| 35 public: | 35 public: |
| 36 virtual void AddRef() { | |
| 37 EXPECT_FALSE(true); | |
| 38 } | |
| 39 virtual void Release() { | |
| 40 EXPECT_FALSE(true); | |
| 41 } | |
| 42 virtual void GetSettingsDone(const printing::PrintSettings& new_settings, | 36 virtual void GetSettingsDone(const printing::PrintSettings& new_settings, |
| 43 printing::PrintingContext::Result result) { | 37 printing::PrintingContext::Result result) { |
| 44 EXPECT_FALSE(true); | 38 EXPECT_FALSE(true); |
| 45 } | 39 } |
| 46 virtual printing::PrintJobWorker* DetachWorker( | 40 virtual printing::PrintJobWorker* DetachWorker( |
| 47 printing::PrintJobWorkerOwner* new_owner) { | 41 printing::PrintJobWorkerOwner* new_owner) { |
| 48 // We're screwing up here since we're calling worker from the main thread. | 42 // We're screwing up here since we're calling worker from the main thread. |
| 49 // That's fine for testing. It is actually simulating PrinterQuery behavior. | 43 // That's fine for testing. It is actually simulating PrinterQuery behavior. |
| 50 TestPrintJobWorker* worker(new TestPrintJobWorker(new_owner)); | 44 TestPrintJobWorker* worker(new TestPrintJobWorker(new_owner)); |
| 51 EXPECT_TRUE(worker->Start()); | 45 EXPECT_TRUE(worker->Start()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // This message loop is actually never run. | 91 // This message loop is actually never run. |
| 98 MessageLoop current; | 92 MessageLoop current; |
| 99 | 93 |
| 100 NotificationRegistrar registrar_; | 94 NotificationRegistrar registrar_; |
| 101 TestPrintNotifObserv observ; | 95 TestPrintNotifObserv observ; |
| 102 registrar_.Add(&observ, NotificationType::ALL, | 96 registrar_.Add(&observ, NotificationType::ALL, |
| 103 NotificationService::AllSources()); | 97 NotificationService::AllSources()); |
| 104 volatile bool check = false; | 98 volatile bool check = false; |
| 105 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); | 99 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); |
| 106 EXPECT_EQ(MessageLoop::current(), job->message_loop()); | 100 EXPECT_EQ(MessageLoop::current(), job->message_loop()); |
| 107 TestOwner owner; | 101 scoped_refptr<TestOwner> owner(new TestOwner); |
| 108 TestSource source; | 102 TestSource source; |
| 109 job->Initialize(&owner, &source); | 103 job->Initialize(owner, &source); |
| 110 job->Stop(); | 104 job->Stop(); |
| 111 job = NULL; | 105 job = NULL; |
| 112 EXPECT_TRUE(check); | 106 EXPECT_TRUE(check); |
| 113 } | 107 } |
| 114 | 108 |
| 115 TEST(PrintJobTest, SimplePrintLateInit) { | 109 TEST(PrintJobTest, SimplePrintLateInit) { |
| 116 volatile bool check = false; | 110 volatile bool check = false; |
| 117 MessageLoop current; | 111 MessageLoop current; |
| 118 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); | 112 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); |
| 119 job = NULL; | 113 job = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 137 job->is_print_dialog_box_shown(); | 131 job->is_print_dialog_box_shown(); |
| 138 job->document(); | 132 job->document(); |
| 139 // Private | 133 // Private |
| 140 job->UpdatePrintedDocument(NULL); | 134 job->UpdatePrintedDocument(NULL); |
| 141 scoped_refptr<printing::JobEventDetails> event_details; | 135 scoped_refptr<printing::JobEventDetails> event_details; |
| 142 job->OnNotifyPrintJobEvent(event_details); | 136 job->OnNotifyPrintJobEvent(event_details); |
| 143 job->OnDocumentDone(); | 137 job->OnDocumentDone(); |
| 144 job->ControlledWorkerShutdown(); | 138 job->ControlledWorkerShutdown(); |
| 145 */ | 139 */ |
| 146 } | 140 } |
| OLD | NEW |