OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/sync/test/integration/printers_helper.h" | 5 #include "chrome/browser/sync/test/integration/printers_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/threading/sequenced_worker_pool.h" | |
16 #include "chrome/browser/chromeos/printing/printers_manager.h" | 17 #include "chrome/browser/chromeos/printing/printers_manager.h" |
17 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" | 18 #include "chrome/browser/chromeos/printing/printers_manager_factory.h" |
18 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 19 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
19 #include "chrome/browser/sync/test/integration/sync_test.h" | 20 #include "chrome/browser/sync/test/integration/sync_test.h" |
21 #include "content/public/browser/browser_thread.h" | |
20 | 22 |
21 using sync_datatype_helper::test; | 23 using sync_datatype_helper::test; |
22 | 24 |
23 namespace printers_helper { | 25 namespace printers_helper { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 using PrinterList = std::vector<std::unique_ptr<chromeos::Printer>>; | 29 using PrinterList = std::vector<std::unique_ptr<chromeos::Printer>>; |
28 | 30 |
29 // Returns true if Printer#id, Printer#description, and Printer#uri all match. | 31 // Returns true if Printer#id, Printer#description, and Printer#uri all match. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 printer.set_uri(base::StringPrintf("ipp://192.168.1.%d", index)); | 105 printer.set_uri(base::StringPrintf("ipp://192.168.1.%d", index)); |
104 | 106 |
105 return printer; | 107 return printer; |
106 } | 108 } |
107 | 109 |
108 chromeos::PrintersManager* GetVerifierPrinterStore() { | 110 chromeos::PrintersManager* GetVerifierPrinterStore() { |
109 chromeos::PrintersManager* manager = | 111 chromeos::PrintersManager* manager = |
110 chromeos::PrintersManagerFactory::GetForBrowserContext( | 112 chromeos::PrintersManagerFactory::GetForBrowserContext( |
111 sync_datatype_helper::test()->verifier()); | 113 sync_datatype_helper::test()->verifier()); |
112 // Must wait for ModelTypeStore initialization. | 114 // Must wait for ModelTypeStore initialization. |
115 // Flush here since PrintersManagerFactory::BuildServiceInstanceFor() uses | |
skym
2017/04/06 16:48:44
Can you expand on this comment. Why are we flushin
Gang Wu
2017/04/06 19:22:59
Done.
| |
116 // content::BrowserThread::GetBlockingPool(). | |
117 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | |
skym
2017/04/06 16:48:44
I don't like how this is being done. Do we really
Gang Wu
2017/04/06 19:22:59
Done.
| |
113 base::RunLoop().RunUntilIdle(); | 118 base::RunLoop().RunUntilIdle(); |
114 | 119 |
115 return manager; | 120 return manager; |
116 } | 121 } |
117 | 122 |
118 chromeos::PrintersManager* GetPrinterStore(int index) { | 123 chromeos::PrintersManager* GetPrinterStore(int index) { |
skym
2017/04/06 16:48:44
This function looks really similar to the above on
Gang Wu
2017/04/06 19:22:59
Done.
| |
119 chromeos::PrintersManager* manager = | 124 chromeos::PrintersManager* manager = |
120 chromeos::PrintersManagerFactory::GetForBrowserContext( | 125 chromeos::PrintersManagerFactory::GetForBrowserContext( |
121 sync_datatype_helper::test()->GetProfile(index)); | 126 sync_datatype_helper::test()->GetProfile(index)); |
122 // Must wait for ModelTypeStore initialization. | 127 // Must wait for ModelTypeStore initialization. |
128 // Flush here since PrintersManagerFactory::BuildServiceInstanceFor() uses | |
129 // content::BrowserThread::GetBlockingPool(). | |
130 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | |
123 base::RunLoop().RunUntilIdle(); | 131 base::RunLoop().RunUntilIdle(); |
124 | 132 |
125 return manager; | 133 return manager; |
126 } | 134 } |
127 | 135 |
128 int GetVerifierPrinterCount() { | 136 int GetVerifierPrinterCount() { |
129 return GetVerifierPrinterStore()->GetPrinters().size(); | 137 return GetVerifierPrinterStore()->GetPrinters().size(); |
130 } | 138 } |
131 | 139 |
132 int GetPrinterCount(int index) { | 140 int GetPrinterCount(int index) { |
(...skipping 19 matching lines...) Expand all Loading... | |
152 } | 160 } |
153 | 161 |
154 PrintersMatchChecker::PrintersMatchChecker() | 162 PrintersMatchChecker::PrintersMatchChecker() |
155 : AwaitMatchStatusChangeChecker( | 163 : AwaitMatchStatusChangeChecker( |
156 base::Bind(&printers_helper::AllProfilesContainSamePrinters), | 164 base::Bind(&printers_helper::AllProfilesContainSamePrinters), |
157 "All printers match") {} | 165 "All printers match") {} |
158 | 166 |
159 PrintersMatchChecker::~PrintersMatchChecker() {} | 167 PrintersMatchChecker::~PrintersMatchChecker() {} |
160 | 168 |
161 } // namespace printers_helper | 169 } // namespace printers_helper |
OLD | NEW |