OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_WEBDRIVER_COMMANDS_WEBDRIVER_COMMAND_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_COMMANDS_WEBDRIVER_COMMAND_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "chrome/test/webdriver/session_manager.h" |
| 12 #include "chrome/test/webdriver/commands/command.h" |
| 13 |
| 14 namespace webdriver { |
| 15 |
| 16 // All URLs that are found in the document: |
| 17 // http://code.google.com/p/selenium/wiki/JsonWireProtocol |
| 18 // and are to be supported for all browsers and platforms should inhert |
| 19 // this class. For cases which do not invlove interaction with the |
| 20 // browser, such a transfering a file, inhert from the Command class |
| 21 // directly. |
| 22 class WebDriverCommand : public Command { |
| 23 public: |
| 24 inline WebDriverCommand(const std::vector<std::string> path_segments, |
| 25 const DictionaryValue* const parameters) |
| 26 : Command(path_segments, parameters), session_(NULL) {} |
| 27 virtual ~WebDriverCommand() {} |
| 28 |
| 29 // Initializes this webdriver command by fetching the command session and, |
| 30 // if necessary, verifying the session has a valid TabProxy. |
| 31 virtual bool Init(Response* const response); |
| 32 |
| 33 protected: |
| 34 static const std::string kElementDictionaryKey; |
| 35 |
| 36 // Tests if |dictionary| contains the kElementDictionaryKey, which |
| 37 // indicates that it represents an element. |
| 38 static bool IsElementIdDictionary(const DictionaryValue* const dictionary); |
| 39 |
| 40 // Returns the |element_id| as a DictionaryValue that conforms with |
| 41 // WebDriver's wire protocol. On success, returns a dynamically allocated |
| 42 // object that the caller is responsible for deleting. Returns NULL on |
| 43 // failure. |
| 44 DictionaryValue* GetElementIdAsDictionaryValue(const std::string& element_id); |
| 45 |
| 46 // Returns whether this command requires a valid TabProxy upon |
| 47 // initialization. |
| 48 virtual bool RequiresValidTab() { return true; } |
| 49 |
| 50 // Returns whether this command has a valid TabProxy. Returns true on |
| 51 // success. Otherwise, returns false and populates the |resposne| with the |
| 52 // necessary information to return to the client. |
| 53 bool VerifyTabIsValid(Response* response); |
| 54 |
| 55 Session* session_; |
| 56 scoped_refptr<TabProxy> tab_; |
| 57 DISALLOW_COPY_AND_ASSIGN(WebDriverCommand); |
| 58 }; |
| 59 } // namespace webdriver |
| 60 #endif // CHROME_TEST_WEBDRIVER_COMMANDS_WEBDRIVER_COMMAND_H_ |
| 61 |
OLD | NEW |