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 // Tests for CppBoundClass, in conjunction with CppBindingExample. Binds | 5 // Tests for CppBoundClass, in conjunction with CppBindingExample. Binds |
6 // a CppBindingExample class into JavaScript in a custom test shell and tests | 6 // a CppBindingExample class into JavaScript in a custom test shell and tests |
7 // the binding from the outside by loading JS into the shell. | 7 // the binding from the outside by loading JS into the shell. |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // text is empty. | 97 // text is empty. |
98 void CheckJavaScriptFailure(const std::string& javascript) { | 98 void CheckJavaScriptFailure(const std::string& javascript) { |
99 ExecuteJavaScript(javascript.c_str()); | 99 ExecuteJavaScript(javascript.c_str()); |
100 EXPECT_EQ( | 100 EXPECT_EQ( |
101 "", | 101 "", |
102 UTF16ToASCII(GetMainFrame()->document().documentElement().innerText())); | 102 UTF16ToASCII(GetMainFrame()->document().documentElement().innerText())); |
103 } | 103 } |
104 | 104 |
105 void CheckTrue(const std::string& expression) { | 105 void CheckTrue(const std::string& expression) { |
106 int was_page_a = -1; | 106 int was_page_a = -1; |
107 string16 check_page_a = | 107 base::string16 check_page_a = |
108 ASCIIToUTF16(std::string("Number(") + expression + ")"); | 108 ASCIIToUTF16(std::string("Number(") + expression + ")"); |
109 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); | 109 EXPECT_TRUE(ExecuteJavaScriptAndReturnIntValue(check_page_a, &was_page_a)); |
110 EXPECT_EQ(1, was_page_a); | 110 EXPECT_EQ(1, was_page_a); |
111 } | 111 } |
112 | 112 |
113 protected: | 113 protected: |
114 virtual bool useFallback() { | 114 virtual bool useFallback() { |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 // Ensures existent methods can be invoked successfully when the fallback method | 234 // Ensures existent methods can be invoked successfully when the fallback method |
235 // is used | 235 // is used |
236 TEST_F(CppBoundClassWithFallbackMethodTest, | 236 TEST_F(CppBoundClassWithFallbackMethodTest, |
237 InvokeExistentMethodsWithFallback) { | 237 InvokeExistentMethodsWithFallback) { |
238 CheckTrue("example.echoValue(34) == 34"); | 238 CheckTrue("example.echoValue(34) == 34"); |
239 } | 239 } |
240 | 240 |
241 } // namespace content | 241 } // namespace content |
OLD | NEW |