| 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/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 std::string json; | 240 std::string json; |
| 241 if (!dom_op_observer.GetResponse(&json)) { | 241 if (!dom_op_observer.GetResponse(&json)) { |
| 242 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; | 242 DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; |
| 243 return false; | 243 return false; |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Nothing more to do for callers that ignore the returned JS value. | 246 // Nothing more to do for callers that ignore the returned JS value. |
| 247 if (!result) | 247 if (!result) |
| 248 return true; | 248 return true; |
| 249 | 249 |
| 250 // Wrap |json| in an array before deserializing because valid JSON has an | 250 base::JSONReader reader(base::JSON_ALLOW_TRAILING_COMMAS); |
| 251 // array or an object as the root. | 251 result->reset(reader.ReadToValue(json)); |
| 252 json.insert(0, "["); | 252 if (!result->get()) { |
| 253 json.append("]"); | 253 DLOG(ERROR) << reader.GetErrorMessage(); |
| 254 | |
| 255 scoped_ptr<Value> root_val( | |
| 256 base::JSONReader::Read(json, base::JSON_ALLOW_TRAILING_COMMAS)); | |
| 257 if (!root_val->IsType(Value::TYPE_LIST)) { | |
| 258 DLOG(ERROR) << "JSON result is not a list."; | |
| 259 return false; | 254 return false; |
| 260 } | 255 } |
| 261 | 256 |
| 262 ListValue* list = static_cast<ListValue*>(root_val.get()); | |
| 263 Value* result_val; | |
| 264 if (!list || !list->GetSize() || | |
| 265 // Remove gives us ownership of the value. | |
| 266 !list->Remove(0, &result_val)) { | |
| 267 DLOG(ERROR) << "JSON result list is empty."; | |
| 268 return false; | |
| 269 } | |
| 270 | |
| 271 result->reset(result_val); | |
| 272 return true; | 257 return true; |
| 273 } | 258 } |
| 274 | 259 |
| 275 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { | 260 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { |
| 276 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 261 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 277 RunMessageLoop(); | 262 RunMessageLoop(); |
| 278 content::BrowserThread::PostTask(thread_id, FROM_HERE, | 263 content::BrowserThread::PostTask(thread_id, FROM_HERE, |
| 279 MessageLoop::QuitClosure()); | 264 MessageLoop::QuitClosure()); |
| 280 } | 265 } |
| 281 | 266 |
| (...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 int state, | 1188 int state, |
| 1204 const base::Closure& followup) { | 1189 const base::Closure& followup) { |
| 1205 if (!followup.is_null()) | 1190 if (!followup.is_null()) |
| 1206 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 1191 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 1207 else | 1192 else |
| 1208 ui_controls::SendMouseEvents(button, state); | 1193 ui_controls::SendMouseEvents(button, state); |
| 1209 } | 1194 } |
| 1210 | 1195 |
| 1211 } // namespace internal | 1196 } // namespace internal |
| 1212 } // namespace ui_test_utils | 1197 } // namespace ui_test_utils |
| OLD | NEW |