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