OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/extension_proxy.h" | 5 #include "chrome/test/automation/extension_proxy.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "chrome/common/automation_messages.h" | 8 #include "chrome/common/automation_messages.h" |
9 #include "chrome/test/automation/automation_proxy.h" | 9 #include "chrome/test/automation/automation_proxy.h" |
10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | 11 |
13 ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender, | 12 ExtensionProxy::ExtensionProxy(AutomationMessageSender* sender, |
14 AutomationHandleTracker* tracker, | 13 AutomationHandleTracker* tracker, |
15 int handle) | 14 int handle) |
16 : AutomationResourceProxy(tracker, sender, handle) { | 15 : AutomationResourceProxy(tracker, sender, handle) { |
17 } | 16 } |
18 | 17 |
19 bool ExtensionProxy::Uninstall() { | 18 bool ExtensionProxy::Uninstall() { |
20 if (!is_valid()) | 19 if (!is_valid()) |
21 return false; | 20 return false; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 int converted_index; | 92 int converted_index; |
94 if (!base::StringToInt(index_string, &converted_index)) { | 93 if (!base::StringToInt(index_string, &converted_index)) { |
95 LOG(ERROR) << "Received index string could not be converted to int: " | 94 LOG(ERROR) << "Received index string could not be converted to int: " |
96 << index_string; | 95 << index_string; |
97 return false; | 96 return false; |
98 } | 97 } |
99 *index = converted_index; | 98 *index = converted_index; |
100 return true; | 99 return true; |
101 } | 100 } |
102 | 101 |
103 void ExtensionProxy::EnsureIdMatches(const std::string& expected_id) { | |
104 std::string id; | |
105 ASSERT_TRUE(GetId(&id)); | |
106 ASSERT_EQ(expected_id, id); | |
107 } | |
108 | |
109 void ExtensionProxy::EnsureNameMatches(const std::string& expected_name) { | |
110 std::string name; | |
111 ASSERT_TRUE(GetName(&name)); | |
112 ASSERT_EQ(expected_name, name); | |
113 } | |
114 | |
115 void ExtensionProxy::EnsureVersionMatches(const std::string& expected_version) { | |
116 std::string version; | |
117 ASSERT_TRUE(GetVersion(&version)); | |
118 ASSERT_EQ(expected_version, version); | |
119 } | |
120 | |
121 void ExtensionProxy::EnsureBrowserActionIndexMatches(int expected_index) { | |
122 int index; | |
123 ASSERT_TRUE(GetBrowserActionIndex(&index)); | |
124 ASSERT_EQ(expected_index, index); | |
125 } | |
126 | |
127 bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type, | 102 bool ExtensionProxy::GetProperty(AutomationMsg_ExtensionProperty type, |
128 std::string* value) { | 103 std::string* value) { |
129 DCHECK(value); | 104 DCHECK(value); |
130 if (!is_valid()) | 105 if (!is_valid()) |
131 return false; | 106 return false; |
132 | 107 |
133 bool success = false; | 108 bool success = false; |
134 if (!sender_->Send(new AutomationMsg_GetExtensionProperty(handle_, type, | 109 if (!sender_->Send(new AutomationMsg_GetExtensionProperty(handle_, type, |
135 &success, value))) | 110 &success, value))) |
136 return false; | 111 return false; |
137 return success; | 112 return success; |
138 } | 113 } |
OLD | NEW |