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

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

Issue 7465041: GTTF: Use a fresh TestingBrowserProcess for each test, part #4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 9 years, 4 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) 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 "chrome/test/testing_browser_process_test.h"
10 #include "content/common/notification_registrar.h" 11 #include "content/common/notification_registrar.h"
11 #include "content/common/notification_service.h" 12 #include "content/common/notification_service.h"
12 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
13 #include "printing/printed_pages_source.h" 14 #include "printing/printed_pages_source.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace { 17 namespace {
17 18
18 class TestSource : public printing::PrintedPagesSource { 19 class TestSource : public printing::PrintedPagesSource {
19 public: 20 public:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 74 }
74 volatile bool* check_; 75 volatile bool* check_;
75 }; 76 };
76 77
77 class TestPrintNotifObserv : public NotificationObserver { 78 class TestPrintNotifObserv : public NotificationObserver {
78 public: 79 public:
79 // NotificationObserver 80 // NotificationObserver
80 virtual void Observe(int type, 81 virtual void Observe(int type,
81 const NotificationSource& source, 82 const NotificationSource& source,
82 const NotificationDetails& details) { 83 const NotificationDetails& details) {
83 EXPECT_FALSE(true); 84 ADD_FAILURE();
84 } 85 }
85 }; 86 };
86 87
87 } // namespace 88 } // namespace
88 89
89 TEST(PrintJobTest, SimplePrint) { 90 typedef TestingBrowserProcessTest PrintJobTest;
91
92 TEST_F(PrintJobTest, SimplePrint) {
90 // Test the multi-threaded nature of PrintJob to make sure we can use it with 93 // Test the multi-threaded nature of PrintJob to make sure we can use it with
91 // known lifetime. 94 // known lifetime.
92 95
93 // This message loop is actually never run. 96 // This message loop is actually never run.
94 MessageLoop current; 97 MessageLoop current;
95 98
96 NotificationRegistrar registrar_; 99 NotificationRegistrar registrar_;
97 TestPrintNotifObserv observ; 100 TestPrintNotifObserv observ;
98 registrar_.Add(&observ, content::NOTIFICATION_ALL, 101 registrar_.Add(&observ, content::NOTIFICATION_ALL,
99 NotificationService::AllSources()); 102 NotificationService::AllSources());
100 volatile bool check = false; 103 volatile bool check = false;
101 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); 104 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check));
102 EXPECT_EQ(MessageLoop::current(), job->message_loop()); 105 EXPECT_EQ(MessageLoop::current(), job->message_loop());
103 scoped_refptr<TestOwner> owner(new TestOwner); 106 scoped_refptr<TestOwner> owner(new TestOwner);
104 TestSource source; 107 TestSource source;
105 job->Initialize(owner, &source, 1); 108 job->Initialize(owner, &source, 1);
106 job->Stop(); 109 job->Stop();
107 job = NULL; 110 job = NULL;
108 EXPECT_TRUE(check); 111 EXPECT_TRUE(check);
109 } 112 }
110 113
111 TEST(PrintJobTest, SimplePrintLateInit) { 114 TEST_F(PrintJobTest, SimplePrintLateInit) {
112 volatile bool check = false; 115 volatile bool check = false;
113 MessageLoop current; 116 MessageLoop current;
114 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check)); 117 scoped_refptr<printing::PrintJob> job(new TestPrintJob(&check));
115 job = NULL; 118 job = NULL;
116 EXPECT_TRUE(check); 119 EXPECT_TRUE(check);
117 /* TODO(maruel): Test these. 120 /* TODO(maruel): Test these.
118 job->Initialize() 121 job->Initialize()
119 job->Observe(); 122 job->Observe();
120 job->GetSettingsDone(); 123 job->GetSettingsDone();
121 job->DetachWorker(); 124 job->DetachWorker();
(...skipping 10 matching lines...) Expand all
132 job->is_job_pending(); 135 job->is_job_pending();
133 job->document(); 136 job->document();
134 // Private 137 // Private
135 job->UpdatePrintedDocument(NULL); 138 job->UpdatePrintedDocument(NULL);
136 scoped_refptr<printing::JobEventDetails> event_details; 139 scoped_refptr<printing::JobEventDetails> event_details;
137 job->OnNotifyPrintJobEvent(event_details); 140 job->OnNotifyPrintJobEvent(event_details);
138 job->OnDocumentDone(); 141 job->OnDocumentDone();
139 job->ControlledWorkerShutdown(); 142 job->ControlledWorkerShutdown();
140 */ 143 */
141 } 144 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud_unittest.cc ('k') | chrome/browser/renderer_host/web_cache_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698