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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 7714004: base: Add AsList() function to Value API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos 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 "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Nothing more to do for callers that ignore the returned JS value. 199 // Nothing more to do for callers that ignore the returned JS value.
200 if (!result) 200 if (!result)
201 return true; 201 return true;
202 202
203 // Wrap |json| in an array before deserializing because valid JSON has an 203 // Wrap |json| in an array before deserializing because valid JSON has an
204 // array or an object as the root. 204 // array or an object as the root.
205 json.insert(0, "["); 205 json.insert(0, "[");
206 json.append("]"); 206 json.append("]");
207 207
208 scoped_ptr<Value> root_val(base::JSONReader::Read(json, true)); 208 scoped_ptr<Value> root_val(base::JSONReader::Read(json, true));
209 if (!root_val->IsType(Value::TYPE_LIST)) 209 ListValue* list = root_val->AsList();
210 if (!list)
210 return false; 211 return false;
211 212
212 ListValue* list = static_cast<ListValue*>(root_val.get());
213 Value* result_val; 213 Value* result_val;
214 if (!list || !list->GetSize() || 214 if (!list || !list->GetSize() ||
215 !list->Remove(0, &result_val)) // Remove gives us ownership of the value. 215 !list->Remove(0, &result_val)) // Remove gives us ownership of the value.
216 return false; 216 return false;
217 217
218 result->reset(result_val); 218 result->reset(result_val);
219 return true; 219 return true;
220 } 220 }
221 221
222 } // namespace 222 } // namespace
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 L"window.domAutomationController.send(" 949 L"window.domAutomationController.send("
950 L" JSON.stringify([document.width, document.height]))"; 950 L" JSON.stringify([document.width, document.height]))";
951 std::string json; 951 std::string json;
952 if (!ui_test_utils::ExecuteJavaScriptAndExtractString( 952 if (!ui_test_utils::ExecuteJavaScriptAndExtractString(
953 rvh, L"", script, &json)) 953 rvh, L"", script, &json))
954 return false; 954 return false;
955 955
956 // Parse the JSON. 956 // Parse the JSON.
957 std::vector<int> dimensions; 957 std::vector<int> dimensions;
958 scoped_ptr<Value> value(base::JSONReader::Read(json, true)); 958 scoped_ptr<Value> value(base::JSONReader::Read(json, true));
959 if (!value->IsType(Value::TYPE_LIST)) 959 ListValue* list = value->AsList();
960 if (!list)
960 return false; 961 return false;
961 ListValue* list = static_cast<ListValue*>(value.get());
962 int width, height; 962 int width, height;
963 if (!list->GetInteger(0, &width) || !list->GetInteger(1, &height)) 963 if (!list->GetInteger(0, &width) || !list->GetInteger(1, &height))
964 return false; 964 return false;
965 965
966 // Take the snapshot. 966 // Take the snapshot.
967 gfx::Size page_size(width, height); 967 gfx::Size page_size(width, height);
968 return TakeRenderWidgetSnapshot(rvh, page_size, page_size, bitmap); 968 return TakeRenderWidgetSnapshot(rvh, page_size, page_size, bitmap);
969 } 969 }
970 970
971 private: 971 private:
(...skipping 20 matching lines...) Expand all
992 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 992 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
993 } 993 }
994 994
995 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 995 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
996 DCHECK(bitmap); 996 DCHECK(bitmap);
997 SnapshotTaker taker; 997 SnapshotTaker taker;
998 return taker.TakeEntirePageSnapshot(rvh, bitmap); 998 return taker.TakeEntirePageSnapshot(rvh, bitmap);
999 } 999 }
1000 1000
1001 } // namespace ui_test_utils 1001 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/automation/value_conversion_traits.cc ('k') | chrome/test/perf/dom_checker_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698