OLD | NEW |
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 "chrome/browser/sync/test/integration/sessions_helper.h" | 5 #include "chrome/browser/sync/test/integration/sessions_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 it != urls.end(); ++it) { | 114 it != urls.end(); ++it) { |
115 DVLOG(1) << "Opening tab: " << it->spec() << " using profile " << index | 115 DVLOG(1) << "Opening tab: " << it->spec() << " using profile " << index |
116 << "."; | 116 << "."; |
117 chrome::ShowSingletonTab(browser, *it); | 117 chrome::ShowSingletonTab(browser, *it); |
118 } | 118 } |
119 return WaitForTabsToLoad(index, urls); | 119 return WaitForTabsToLoad(index, urls); |
120 } | 120 } |
121 | 121 |
122 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) { | 122 bool WaitForTabsToLoad(int index, const std::vector<GURL>& urls) { |
123 DVLOG(1) << "Waiting for session to propagate to associator."; | 123 DVLOG(1) << "Waiting for session to propagate to associator."; |
124 static const int timeout_milli = TestTimeouts::action_max_timeout_ms(); | |
125 base::TimeTicks start_time = base::TimeTicks::Now(); | 124 base::TimeTicks start_time = base::TimeTicks::Now(); |
126 base::TimeTicks end_time = start_time + | 125 base::TimeTicks end_time = start_time + TestTimeouts::action_max_timeout(); |
127 base::TimeDelta::FromMilliseconds(timeout_milli); | |
128 bool found; | 126 bool found; |
129 for (std::vector<GURL>::const_iterator it = urls.begin(); | 127 for (std::vector<GURL>::const_iterator it = urls.begin(); |
130 it != urls.end(); ++it) { | 128 it != urls.end(); ++it) { |
131 found = false; | 129 found = false; |
132 while (!found) { | 130 while (!found) { |
133 found = ModelAssociatorHasTabWithUrl(index, *it); | 131 found = ModelAssociatorHasTabWithUrl(index, *it); |
134 if (base::TimeTicks::Now() >= end_time) { | 132 if (base::TimeTicks::Now() >= end_time) { |
135 LOG(ERROR) << "Failed to find all tabs after " << timeout_milli/1000.0 | 133 LOG(ERROR) << "Failed to find all tabs after " |
| 134 << TestTimeouts::action_max_timeout().InSecondsF() |
136 << " seconds."; | 135 << " seconds."; |
137 return false; | 136 return false; |
138 } | 137 } |
139 if (!found) { | 138 if (!found) { |
140 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 139 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
141 test()->GetProfile(index))->GetSessionModelAssociator()-> | 140 test()->GetProfile(index))->GetSessionModelAssociator()-> |
142 BlockUntilLocalChangeForTest(timeout_milli); | 141 BlockUntilLocalChangeForTest(TestTimeouts::action_max_timeout()); |
143 ui_test_utils::RunMessageLoop(); | 142 ui_test_utils::RunMessageLoop(); |
144 } | 143 } |
145 } | 144 } |
146 } | 145 } |
147 return true; | 146 return true; |
148 } | 147 } |
149 | 148 |
150 bool GetLocalWindows(int index, SessionWindowMap* local_windows) { | 149 bool GetLocalWindows(int index, SessionWindowMap* local_windows) { |
151 // The local session provided by GetLocalSession is owned, and has lifetime | 150 // The local session provided by GetLocalSession is owned, and has lifetime |
152 // controlled, by the model associator, so we must make our own copy. | 151 // controlled, by the model associator, so we must make our own copy. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 return true; | 307 return true; |
309 } | 308 } |
310 | 309 |
311 void DeleteForeignSession(int index, std::string session_tag) { | 310 void DeleteForeignSession(int index, std::string session_tag) { |
312 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 311 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
313 test()->GetProfile(index))-> | 312 test()->GetProfile(index))-> |
314 GetSessionModelAssociator()->DeleteForeignSession(session_tag); | 313 GetSessionModelAssociator()->DeleteForeignSession(session_tag); |
315 } | 314 } |
316 | 315 |
317 } // namespace sessions_helper | 316 } // namespace sessions_helper |
OLD | NEW |