OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "base/string16.h" | 6 #include "base/string16.h" |
7 #include "chrome/browser/printing/print_job.h" | 7 #include "chrome/browser/printing/print_job.h" |
8 #include "chrome/browser/printing/print_job_worker.h" | 8 #include "chrome/browser/printing/print_job_worker.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "content/public/browser/notification_registrar.h" | 10 #include "content/public/browser/notification_registrar.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
79 const content::NotificationDetails& details) { | 79 const content::NotificationDetails& details) { |
80 ADD_FAILURE(); | 80 ADD_FAILURE(); |
81 } | 81 } |
82 }; | 82 }; |
83 | 83 |
84 } // namespace | 84 } // namespace |
85 | 85 |
86 typedef testing::Test PrintJobTest; | 86 typedef testing::Test PrintJobTest; |
87 | 87 |
88 // Crashes under Linux Aura, see http://crbug.com/100340 | 88 #if !defined(USE_AURA) |
89 #if defined(USE_AURA) && !defined(OS_WIN) | 89 TEST_F(PrintJobTest, SimplePrint) { |
90 #define MAYBE_SimplePrint DISABLED_SimplePrint | |
91 #else | |
92 #define MAYBE_SimplePrint SimplePrint | |
93 #endif | |
94 TEST_F(PrintJobTest, MAYBE_SimplePrint) { | |
95 // Test the multi-threaded nature of PrintJob to make sure we can use it with | 90 // Test the multi-threaded nature of PrintJob to make sure we can use it with |
96 // known lifetime. | 91 // known lifetime. |
97 | 92 |
98 // This message loop is actually never run. | 93 // This message loop is actually never run. |
99 MessageLoop current; | 94 MessageLoop current; |
100 | 95 |
101 content::NotificationRegistrar registrar_; | 96 content::NotificationRegistrar registrar_; |
102 TestPrintNotifObserv observ; | 97 TestPrintNotifObserv observ; |
103 registrar_.Add(&observ, content::NOTIFICATION_ALL, | 98 registrar_.Add(&observ, content::NOTIFICATION_ALL, |
104 content::NotificationService::AllSources()); | 99 content::NotificationService::AllSources()); |
105 volatile bool check = false; | 100 volatile bool check = false; |
106 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); | 101 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); |
107 EXPECT_EQ(MessageLoop::current(), job->message_loop()); | 102 EXPECT_EQ(MessageLoop::current(), job->message_loop()); |
108 scoped_refptr<TestOwner> owner(new TestOwner); | 103 scoped_refptr<TestOwner> owner(new TestOwner); |
109 TestSource source; | 104 TestSource source; |
110 job->Initialize(owner, &source, 1); | 105 job->Initialize(owner, &source, 1); |
111 job->Stop(); | 106 job->Stop(); |
112 job = NULL; | 107 job = NULL; |
113 EXPECT_TRUE(check); | 108 EXPECT_TRUE(check); |
114 } | 109 } |
| 110 #endif |
115 | 111 |
116 TEST_F(PrintJobTest, SimplePrintLateInit) { | 112 TEST_F(PrintJobTest, SimplePrintLateInit) { |
117 volatile bool check = false; | 113 volatile bool check = false; |
118 MessageLoop current; | 114 MessageLoop current; |
119 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); | 115 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); |
120 job = NULL; | 116 job = NULL; |
121 EXPECT_TRUE(check); | 117 EXPECT_TRUE(check); |
122 /* TODO(maruel): Test these. | 118 /* TODO(maruel): Test these. |
123 job->Initialize() | 119 job->Initialize() |
124 job->Observe(); | 120 job->Observe(); |
(...skipping 12 matching lines...) Expand all Loading... |
137 job->is_job_pending(); | 133 job->is_job_pending(); |
138 job->document(); | 134 job->document(); |
139 // Private | 135 // Private |
140 job->UpdatePrintedDocument(NULL); | 136 job->UpdatePrintedDocument(NULL); |
141 scoped_refptr<printing::JobEventDetails> event_details; | 137 scoped_refptr<printing::JobEventDetails> event_details; |
142 job->OnNotifyPrintJobEvent(event_details); | 138 job->OnNotifyPrintJobEvent(event_details); |
143 job->OnDocumentDone(); | 139 job->OnDocumentDone(); |
144 job->ControlledWorkerShutdown(); | 140 job->ControlledWorkerShutdown(); |
145 */ | 141 */ |
146 } | 142 } |
OLD | NEW |