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

Side by Side Diff: chrome/browser/printing/print_job_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 28 matching lines...) Expand all
39 virtual printing::PrintJobWorker* DetachWorker( 39 virtual printing::PrintJobWorker* DetachWorker(
40 printing::PrintJobWorkerOwner* new_owner) OVERRIDE { 40 printing::PrintJobWorkerOwner* new_owner) OVERRIDE {
41 // We're screwing up here since we're calling worker from the main thread. 41 // We're screwing up here since we're calling worker from the main thread.
42 // That's fine for testing. It is actually simulating PrinterQuery behavior. 42 // That's fine for testing. It is actually simulating PrinterQuery behavior.
43 TestPrintJobWorker* worker(new TestPrintJobWorker(new_owner)); 43 TestPrintJobWorker* worker(new TestPrintJobWorker(new_owner));
44 EXPECT_TRUE(worker->Start()); 44 EXPECT_TRUE(worker->Start());
45 worker->printing_context()->UseDefaultSettings(); 45 worker->printing_context()->UseDefaultSettings();
46 settings_ = worker->printing_context()->settings(); 46 settings_ = worker->printing_context()->settings();
47 return worker; 47 return worker;
48 } 48 }
49 virtual MessageLoop* message_loop() OVERRIDE { 49 virtual base::MessageLoop* message_loop() OVERRIDE {
50 EXPECT_FALSE(true); 50 EXPECT_FALSE(true);
51 return NULL; 51 return NULL;
52 } 52 }
53 virtual const printing::PrintSettings& settings() const OVERRIDE { 53 virtual const printing::PrintSettings& settings() const OVERRIDE {
54 return settings_; 54 return settings_;
55 } 55 }
56 virtual int cookie() const OVERRIDE { 56 virtual int cookie() const OVERRIDE {
57 return 42; 57 return 42;
58 } 58 }
59 59
(...skipping 26 matching lines...) Expand all
86 86
87 } // namespace 87 } // namespace
88 88
89 typedef testing::Test PrintJobTest; 89 typedef testing::Test PrintJobTest;
90 90
91 TEST_F(PrintJobTest, SimplePrint) { 91 TEST_F(PrintJobTest, SimplePrint) {
92 // Test the multi-threaded nature of PrintJob to make sure we can use it with 92 // Test the multi-threaded nature of PrintJob to make sure we can use it with
93 // known lifetime. 93 // known lifetime.
94 94
95 // This message loop is actually never run. 95 // This message loop is actually never run.
96 MessageLoop current; 96 base::MessageLoop current;
97 97
98 content::NotificationRegistrar registrar_; 98 content::NotificationRegistrar registrar_;
99 TestPrintNotifObserv observ; 99 TestPrintNotifObserv observ;
100 registrar_.Add(&observ, content::NOTIFICATION_ALL, 100 registrar_.Add(&observ, content::NOTIFICATION_ALL,
101 content::NotificationService::AllSources()); 101 content::NotificationService::AllSources());
102 volatile bool check = false; 102 volatile bool check = false;
103 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); 103 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check));
104 EXPECT_EQ(MessageLoop::current(), job->message_loop()); 104 EXPECT_EQ(base::MessageLoop::current(), job->message_loop());
105 scoped_refptr<TestOwner> owner(new TestOwner); 105 scoped_refptr<TestOwner> owner(new TestOwner);
106 TestSource source; 106 TestSource source;
107 job->Initialize(owner, &source, 1); 107 job->Initialize(owner, &source, 1);
108 job->Stop(); 108 job->Stop();
109 job = NULL; 109 job = NULL;
110 EXPECT_TRUE(check); 110 EXPECT_TRUE(check);
111 } 111 }
112 112
113 TEST_F(PrintJobTest, SimplePrintLateInit) { 113 TEST_F(PrintJobTest, SimplePrintLateInit) {
114 volatile bool check = false; 114 volatile bool check = false;
115 MessageLoop current; 115 base::MessageLoop current;
116 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); 116 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check));
117 job = NULL; 117 job = NULL;
118 EXPECT_TRUE(check); 118 EXPECT_TRUE(check);
119 /* TODO(maruel): Test these. 119 /* TODO(maruel): Test these.
120 job->Initialize() 120 job->Initialize()
121 job->Observe(); 121 job->Observe();
122 job->GetSettingsDone(); 122 job->GetSettingsDone();
123 job->DetachWorker(); 123 job->DetachWorker();
124 job->message_loop(); 124 job->message_loop();
125 job->settings(); 125 job->settings();
126 job->cookie(); 126 job->cookie();
127 job->GetSettings(printing::DEFAULTS, printing::ASK_USER, NULL); 127 job->GetSettings(printing::DEFAULTS, printing::ASK_USER, NULL);
128 job->StartPrinting(); 128 job->StartPrinting();
129 job->Stop(); 129 job->Stop();
130 job->Cancel(); 130 job->Cancel();
131 job->RequestMissingPages(); 131 job->RequestMissingPages();
132 job->FlushJob(timeout); 132 job->FlushJob(timeout);
133 job->DisconnectSource(); 133 job->DisconnectSource();
134 job->is_job_pending(); 134 job->is_job_pending();
135 job->document(); 135 job->document();
136 // Private 136 // Private
137 job->UpdatePrintedDocument(NULL); 137 job->UpdatePrintedDocument(NULL);
138 scoped_refptr<printing::JobEventDetails> event_details; 138 scoped_refptr<printing::JobEventDetails> event_details;
139 job->OnNotifyPrintJobEvent(event_details); 139 job->OnNotifyPrintJobEvent(event_details);
140 job->OnDocumentDone(); 140 job->OnDocumentDone();
141 job->ControlledWorkerShutdown(); 141 job->ControlledWorkerShutdown();
142 */ 142 */
143 } 143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698