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

Side by Side Diff: chrome/test/webdriver/session.cc

Issue 7523060: Let pyauto create an attached webdriver instance to manipulate web pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (ProxyLauncher third option no longer required) 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
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webdriver/session.h" 5 #include "chrome/test/webdriver/session.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 implicit_wait_(0), 70 implicit_wait_(0),
71 has_alert_prompt_text_(false), 71 has_alert_prompt_text_(false),
72 options_(options) { 72 options_(options) {
73 SessionManager::GetInstance()->Add(this); 73 SessionManager::GetInstance()->Add(this);
74 } 74 }
75 75
76 Session::~Session() { 76 Session::~Session() {
77 SessionManager::GetInstance()->Remove(id_); 77 SessionManager::GetInstance()->Remove(id_);
78 } 78 }
79 79
80 Error* Session::Init(const FilePath& browser_exe, 80 Error* Session::Init(const Automation::BrowserOptions& options) {
81 const FilePath& user_data_dir,
82 const CommandLine& options) {
83 if (!thread_.Start()) { 81 if (!thread_.Start()) {
84 delete this; 82 delete this;
85 return new Error(kUnknownError, "Cannot start session thread"); 83 return new Error(kUnknownError, "Cannot start session thread");
86 } 84 }
87 85
88 Error* error = NULL; 86 Error* error = NULL;
89 RunSessionTask(NewRunnableMethod( 87 RunSessionTask(NewRunnableMethod(
90 this, 88 this,
91 &Session::InitOnSessionThread, 89 &Session::InitOnSessionThread,
92 browser_exe,
93 user_data_dir,
94 options, 90 options,
95 &error)); 91 &error));
96 if (error) 92 if (error)
97 Terminate(); 93 Terminate();
98 return error; 94 return error;
99 } 95 }
100 96
101 Error* Session::BeforeExecuteCommand() { 97 Error* Session::BeforeExecuteCommand() {
102 Error* error = NULL; 98 Error* error = NULL;
103 if (!options_.load_async) { 99 if (!options_.load_async) {
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 done_event.Wait(); 1113 done_event.Wait();
1118 } 1114 }
1119 1115
1120 void Session::RunSessionTaskOnSessionThread(Task* task, 1116 void Session::RunSessionTaskOnSessionThread(Task* task,
1121 base::WaitableEvent* done_event) { 1117 base::WaitableEvent* done_event) {
1122 task->Run(); 1118 task->Run();
1123 delete task; 1119 delete task;
1124 done_event->Signal(); 1120 done_event->Signal();
1125 } 1121 }
1126 1122
1127 void Session::InitOnSessionThread(const FilePath& browser_exe, 1123
1128 const FilePath& user_data_dir, 1124 void Session::InitOnSessionThread(const Automation::BrowserOptions& options,
1129 const CommandLine& options,
1130 Error** error) { 1125 Error** error) {
1131 automation_.reset(new Automation()); 1126 automation_.reset(new Automation());
1132 if (browser_exe.empty()) { 1127 automation_->Init(options, error);
1133 automation_->Init(options, user_data_dir, error);
1134 } else {
1135 automation_->InitWithBrowserPath(
1136 browser_exe, user_data_dir, options, error);
1137 }
1138
1139 if (*error) 1128 if (*error)
1140 return; 1129 return;
1141 1130
1142 std::vector<int> tab_ids; 1131 std::vector<int> tab_ids;
1143 automation_->GetTabIds(&tab_ids, error); 1132 automation_->GetTabIds(&tab_ids, error);
1144 if (*error) 1133 if (*error)
1145 return; 1134 return;
1146 if (tab_ids.empty()) { 1135 if (tab_ids.empty()) {
1147 *error = new Error(kUnknownError, "No tab ids after initialization"); 1136 *error = new Error(kUnknownError, "No tab ids after initialization");
1148 return; 1137 return;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 path, 1480 path,
1492 &error)); 1481 &error));
1493 if (error) 1482 if (error)
1494 return error; 1483 return error;
1495 if (!file_util::ReadFileToString(path, png)) 1484 if (!file_util::ReadFileToString(path, png))
1496 return new Error(kUnknownError, "Could not read screenshot file"); 1485 return new Error(kUnknownError, "Could not read screenshot file");
1497 return NULL; 1486 return NULL;
1498 } 1487 }
1499 1488
1500 } // namespace webdriver 1489 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698