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

Side by Side Diff: content/browser/android/java/gin_java_method_invocation_helper_unittest.cc

Issue 629183002: Replacing the OVERRIDE with override and FINAL with final in content/browser/android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolving Error in android Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/android/java/gin_java_method_invocation_helper.h" 5 #include "content/browser/android/java/gin_java_method_invocation_helper.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "content/browser/android/java/jni_helper.h" 8 #include "content/browser/android/java/jni_helper.h"
9 #include "content/common/android/gin_java_bridge_value.h" 9 #include "content/common/android/gin_java_bridge_value.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 namespace { 14 namespace {
15 15
16 class NullObjectDelegate 16 class NullObjectDelegate
17 : public GinJavaMethodInvocationHelper::ObjectDelegate { 17 : public GinJavaMethodInvocationHelper::ObjectDelegate {
18 public: 18 public:
19 NullObjectDelegate() {} 19 NullObjectDelegate() {}
20 20
21 virtual ~NullObjectDelegate() {} 21 virtual ~NullObjectDelegate() {}
22 22
23 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( 23 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef(
24 JNIEnv* env) OVERRIDE { 24 JNIEnv* env) override {
25 return base::android::ScopedJavaLocalRef<jobject>(); 25 return base::android::ScopedJavaLocalRef<jobject>();
26 } 26 }
27 27
28 virtual base::android::ScopedJavaLocalRef<jclass> GetLocalClassRef( 28 virtual base::android::ScopedJavaLocalRef<jclass> GetLocalClassRef(
29 JNIEnv* env) OVERRIDE { 29 JNIEnv* env) override {
30 return base::android::ScopedJavaLocalRef<jclass>(); 30 return base::android::ScopedJavaLocalRef<jclass>();
31 } 31 }
32 32
33 virtual const JavaMethod* FindMethod(const std::string& method_name, 33 virtual const JavaMethod* FindMethod(const std::string& method_name,
34 size_t num_parameters) OVERRIDE { 34 size_t num_parameters) override {
35 return NULL; 35 return NULL;
36 } 36 }
37 37
38 virtual bool IsObjectGetClassMethod(const JavaMethod* method) OVERRIDE { 38 virtual bool IsObjectGetClassMethod(const JavaMethod* method) override {
39 return false; 39 return false;
40 } 40 }
41 41
42 virtual const base::android::JavaRef<jclass>& GetSafeAnnotationClass() 42 virtual const base::android::JavaRef<jclass>& GetSafeAnnotationClass()
43 OVERRIDE { 43 override {
44 return safe_annotation_class_; 44 return safe_annotation_class_;
45 } 45 }
46 46
47 private: 47 private:
48 base::android::ScopedJavaLocalRef<jclass> safe_annotation_class_; 48 base::android::ScopedJavaLocalRef<jclass> safe_annotation_class_;
49 49
50 DISALLOW_COPY_AND_ASSIGN(NullObjectDelegate); 50 DISALLOW_COPY_AND_ASSIGN(NullObjectDelegate);
51 }; 51 };
52 52
53 class NullDispatcherDelegate 53 class NullDispatcherDelegate
54 : public GinJavaMethodInvocationHelper::DispatcherDelegate { 54 : public GinJavaMethodInvocationHelper::DispatcherDelegate {
55 public: 55 public:
56 NullDispatcherDelegate() {} 56 NullDispatcherDelegate() {}
57 57
58 virtual ~NullDispatcherDelegate() {} 58 virtual ~NullDispatcherDelegate() {}
59 59
60 virtual JavaObjectWeakGlobalRef GetObjectWeakRef( 60 virtual JavaObjectWeakGlobalRef GetObjectWeakRef(
61 GinJavaBoundObject::ObjectID object_id) OVERRIDE { 61 GinJavaBoundObject::ObjectID object_id) override {
62 return JavaObjectWeakGlobalRef(); 62 return JavaObjectWeakGlobalRef();
63 } 63 }
64 64
65 DISALLOW_COPY_AND_ASSIGN(NullDispatcherDelegate); 65 DISALLOW_COPY_AND_ASSIGN(NullDispatcherDelegate);
66 }; 66 };
67 67
68 } // namespace 68 } // namespace
69 69
70 class GinJavaMethodInvocationHelperTest : public testing::Test { 70 class GinJavaMethodInvocationHelperTest : public testing::Test {
71 }; 71 };
72 72
73 namespace { 73 namespace {
74 74
75 class CountingDispatcherDelegate 75 class CountingDispatcherDelegate
76 : public GinJavaMethodInvocationHelper::DispatcherDelegate { 76 : public GinJavaMethodInvocationHelper::DispatcherDelegate {
77 public: 77 public:
78 CountingDispatcherDelegate() {} 78 CountingDispatcherDelegate() {}
79 79
80 virtual ~CountingDispatcherDelegate() {} 80 virtual ~CountingDispatcherDelegate() {}
81 81
82 virtual JavaObjectWeakGlobalRef GetObjectWeakRef( 82 virtual JavaObjectWeakGlobalRef GetObjectWeakRef(
83 GinJavaBoundObject::ObjectID object_id) OVERRIDE { 83 GinJavaBoundObject::ObjectID object_id) override {
84 counters_[object_id]++; 84 counters_[object_id]++;
85 return JavaObjectWeakGlobalRef(); 85 return JavaObjectWeakGlobalRef();
86 } 86 }
87 87
88 void AssertInvocationsCount(GinJavaBoundObject::ObjectID begin_object_id, 88 void AssertInvocationsCount(GinJavaBoundObject::ObjectID begin_object_id,
89 GinJavaBoundObject::ObjectID end_object_id) { 89 GinJavaBoundObject::ObjectID end_object_id) {
90 EXPECT_EQ(end_object_id - begin_object_id, 90 EXPECT_EQ(end_object_id - begin_object_id,
91 static_cast<int>(counters_.size())); 91 static_cast<int>(counters_.size()));
92 for (GinJavaBoundObject::ObjectID i = begin_object_id; 92 for (GinJavaBoundObject::ObjectID i = begin_object_id;
93 i < end_object_id; ++i) { 93 i < end_object_id; ++i) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 base::android::GetClass(env, "java/lang/Object").obj(), 172 base::android::GetClass(env, "java/lang/Object").obj(),
173 method_id, 173 method_id,
174 false)); 174 false));
175 EXPECT_TRUE(method_obj.obj()); 175 EXPECT_TRUE(method_obj.obj());
176 method_.reset(new JavaMethod(method_obj)); 176 method_.reset(new JavaMethod(method_obj));
177 } 177 }
178 178
179 virtual ~ObjectIsGoneObjectDelegate() {} 179 virtual ~ObjectIsGoneObjectDelegate() {}
180 180
181 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( 181 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef(
182 JNIEnv* env) OVERRIDE { 182 JNIEnv* env) override {
183 get_local_ref_called_ = true; 183 get_local_ref_called_ = true;
184 return NullObjectDelegate::GetLocalRef(env); 184 return NullObjectDelegate::GetLocalRef(env);
185 } 185 }
186 186
187 virtual const JavaMethod* FindMethod(const std::string& method_name, 187 virtual const JavaMethod* FindMethod(const std::string& method_name,
188 size_t num_parameters) OVERRIDE { 188 size_t num_parameters) override {
189 return method_.get(); 189 return method_.get();
190 } 190 }
191 191
192 bool get_local_ref_called() { return get_local_ref_called_; } 192 bool get_local_ref_called() { return get_local_ref_called_; }
193 193
194 const std::string& get_method_name() { return method_->name(); } 194 const std::string& get_method_name() { return method_->name(); }
195 195
196 protected: 196 protected:
197 scoped_ptr<JavaMethod> method_; 197 scoped_ptr<JavaMethod> method_;
198 bool get_local_ref_called_; 198 bool get_local_ref_called_;
(...skipping 27 matching lines...) Expand all
226 226
227 namespace { 227 namespace {
228 228
229 class MethodNotFoundObjectDelegate : public NullObjectDelegate { 229 class MethodNotFoundObjectDelegate : public NullObjectDelegate {
230 public: 230 public:
231 MethodNotFoundObjectDelegate() : find_method_called_(false) {} 231 MethodNotFoundObjectDelegate() : find_method_called_(false) {}
232 232
233 virtual ~MethodNotFoundObjectDelegate() {} 233 virtual ~MethodNotFoundObjectDelegate() {}
234 234
235 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef( 235 virtual base::android::ScopedJavaLocalRef<jobject> GetLocalRef(
236 JNIEnv* env) OVERRIDE { 236 JNIEnv* env) override {
237 return base::android::ScopedJavaLocalRef<jobject>( 237 return base::android::ScopedJavaLocalRef<jobject>(
238 env, static_cast<jobject>(env->FindClass("java/lang/String"))); 238 env, static_cast<jobject>(env->FindClass("java/lang/String")));
239 } 239 }
240 240
241 virtual const JavaMethod* FindMethod(const std::string& method_name, 241 virtual const JavaMethod* FindMethod(const std::string& method_name,
242 size_t num_parameters) OVERRIDE { 242 size_t num_parameters) override {
243 find_method_called_ = true; 243 find_method_called_ = true;
244 return NULL; 244 return NULL;
245 } 245 }
246 246
247 bool find_method_called() const { return find_method_called_; } 247 bool find_method_called() const { return find_method_called_; }
248 248
249 protected: 249 protected:
250 bool find_method_called_; 250 bool find_method_called_;
251 251
252 private: 252 private:
(...skipping 25 matching lines...) Expand all
278 278
279 namespace { 279 namespace {
280 280
281 class GetClassObjectDelegate : public MethodNotFoundObjectDelegate { 281 class GetClassObjectDelegate : public MethodNotFoundObjectDelegate {
282 public: 282 public:
283 GetClassObjectDelegate() : get_class_called_(false) {} 283 GetClassObjectDelegate() : get_class_called_(false) {}
284 284
285 virtual ~GetClassObjectDelegate() {} 285 virtual ~GetClassObjectDelegate() {}
286 286
287 virtual const JavaMethod* FindMethod(const std::string& method_name, 287 virtual const JavaMethod* FindMethod(const std::string& method_name,
288 size_t num_parameters) OVERRIDE { 288 size_t num_parameters) override {
289 find_method_called_ = true; 289 find_method_called_ = true;
290 return kFakeGetClass; 290 return kFakeGetClass;
291 } 291 }
292 292
293 virtual bool IsObjectGetClassMethod(const JavaMethod* method) OVERRIDE { 293 virtual bool IsObjectGetClassMethod(const JavaMethod* method) override {
294 get_class_called_ = true; 294 get_class_called_ = true;
295 return kFakeGetClass == method; 295 return kFakeGetClass == method;
296 } 296 }
297 297
298 bool get_class_called() const { return get_class_called_; } 298 bool get_class_called() const { return get_class_called_; }
299 299
300 private: 300 private:
301 static const JavaMethod* kFakeGetClass; 301 static const JavaMethod* kFakeGetClass;
302 bool get_class_called_; 302 bool get_class_called_;
303 303
(...skipping 26 matching lines...) Expand all
330 helper->Invoke(); 330 helper->Invoke();
331 EXPECT_TRUE(object_delegate->find_method_called()); 331 EXPECT_TRUE(object_delegate->find_method_called());
332 EXPECT_TRUE(object_delegate->get_class_called()); 332 EXPECT_TRUE(object_delegate->get_class_called());
333 EXPECT_TRUE(helper->HoldsPrimitiveResult()); 333 EXPECT_TRUE(helper->HoldsPrimitiveResult());
334 EXPECT_TRUE(helper->GetPrimitiveResult().empty()); 334 EXPECT_TRUE(helper->GetPrimitiveResult().empty());
335 EXPECT_EQ(kGinJavaBridgeAccessToObjectGetClassIsBlocked, 335 EXPECT_EQ(kGinJavaBridgeAccessToObjectGetClassIsBlocked,
336 helper->GetInvocationError()); 336 helper->GetInvocationError());
337 } 337 }
338 338
339 } // namespace content 339 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/java/gin_java_bridge_dispatcher_host.cc ('k') | content/browser/android/popup_touch_handle_drawable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698