| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/test/automation/autocomplete_edit_proxy.h" | 5 #include "chrome/test/automation/autocomplete_edit_proxy.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/threading/platform_thread.h" |
| 9 #include "chrome/common/automation_constants.h" | 10 #include "chrome/common/automation_constants.h" |
| 10 #include "chrome/common/automation_messages.h" | 11 #include "chrome/common/automation_messages.h" |
| 11 #include "chrome/test/automation/automation_proxy.h" | 12 #include "chrome/test/automation/automation_proxy.h" |
| 12 | 13 |
| 13 using base::TimeDelta; | 14 using base::TimeDelta; |
| 14 using base::TimeTicks; | 15 using base::TimeTicks; |
| 15 | 16 |
| 16 bool AutocompleteEditProxy::GetText(std::wstring* text) const { | 17 bool AutocompleteEditProxy::GetText(std::wstring* text) const { |
| 17 if (!is_valid()) | 18 if (!is_valid()) |
| 18 return false; | 19 return false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 60 |
| 60 bool AutocompleteEditProxy::WaitForQuery(int wait_timeout_ms) const { | 61 bool AutocompleteEditProxy::WaitForQuery(int wait_timeout_ms) const { |
| 61 // TODO(jknotten): use a delayed message / observer instead. | 62 // TODO(jknotten): use a delayed message / observer instead. |
| 62 // See, for example, AutocompleteEditProxy::WaitForFocus. | 63 // See, for example, AutocompleteEditProxy::WaitForFocus. |
| 63 const TimeTicks start = TimeTicks::Now(); | 64 const TimeTicks start = TimeTicks::Now(); |
| 64 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout_ms); | 65 const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout_ms); |
| 65 bool query_in_progress; | 66 bool query_in_progress; |
| 66 while (TimeTicks::Now() - start < timeout) { | 67 while (TimeTicks::Now() - start < timeout) { |
| 67 if (IsQueryInProgress(&query_in_progress) && !query_in_progress) | 68 if (IsQueryInProgress(&query_in_progress) && !query_in_progress) |
| 68 return true; | 69 return true; |
| 69 PlatformThread::Sleep(automation::kSleepTime); | 70 base::PlatformThread::Sleep(automation::kSleepTime); |
| 70 } | 71 } |
| 71 // If we get here the query is still in progress. | 72 // If we get here the query is still in progress. |
| 72 return false; | 73 return false; |
| 73 } | 74 } |
| 74 | 75 |
| 75 bool AutocompleteEditProxy::GetAutocompleteMatches(Matches* matches) const { | 76 bool AutocompleteEditProxy::GetAutocompleteMatches(Matches* matches) const { |
| 76 if (!is_valid()) | 77 if (!is_valid()) |
| 77 return false; | 78 return false; |
| 78 if (!matches) { | 79 if (!matches) { |
| 79 NOTREACHED(); | 80 NOTREACHED(); |
| 80 return false; | 81 return false; |
| 81 } | 82 } |
| 82 bool edit_exists = false; | 83 bool edit_exists = false; |
| 83 sender_->Send(new AutomationMsg_AutocompleteEditGetMatches( | 84 sender_->Send(new AutomationMsg_AutocompleteEditGetMatches( |
| 84 handle_, &edit_exists, matches)); | 85 handle_, &edit_exists, matches)); |
| 85 return edit_exists; | 86 return edit_exists; |
| 86 } | 87 } |
| OLD | NEW |