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

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

Issue 2811253004: Remove ListValue::Append(raw ptr) on Android (Closed)
Patch Set: Comments Created 3 years, 8 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility>
10
9 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
10 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
14 #include "base/values.h"
11 #include "content/browser/android/java/jni_helper.h" 15 #include "content/browser/android/java/jni_helper.h"
12 #include "content/common/android/gin_java_bridge_value.h" 16 #include "content/common/android/gin_java_bridge_value.h"
13 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
14 18
15 namespace content { 19 namespace content {
16 20
17 namespace { 21 namespace {
18 22
19 class NullObjectDelegate 23 class NullObjectDelegate
20 : public GinJavaMethodInvocationHelper::ObjectDelegate { 24 : public GinJavaMethodInvocationHelper::ObjectDelegate {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 new NullObjectDelegate()), 121 new NullObjectDelegate()),
118 "foo", no_objects); 122 "foo", no_objects);
119 CountingDispatcherDelegate counter; 123 CountingDispatcherDelegate counter;
120 helper->Init(&counter); 124 helper->Init(&counter);
121 counter.AssertInvocationsCount(0, 0); 125 counter.AssertInvocationsCount(0, 0);
122 } 126 }
123 127
124 TEST_F(GinJavaMethodInvocationHelperTest, RetrievalOfObjectsHaveObjects) { 128 TEST_F(GinJavaMethodInvocationHelperTest, RetrievalOfObjectsHaveObjects) {
125 base::ListValue objects; 129 base::ListValue objects;
126 objects.AppendInteger(100); 130 objects.AppendInteger(100);
127 objects.Append(GinJavaBridgeValue::CreateObjectIDValue(1).release()); 131 objects.Append(GinJavaBridgeValue::CreateObjectIDValue(1));
128 base::ListValue* sub_list = new base::ListValue(); 132 auto sub_list = base::MakeUnique<base::ListValue>();
129 sub_list->AppendInteger(200); 133 sub_list->AppendInteger(200);
130 sub_list->Append(GinJavaBridgeValue::CreateObjectIDValue(2).release()); 134 sub_list->Append(GinJavaBridgeValue::CreateObjectIDValue(2));
131 objects.Append(sub_list); 135 objects.Append(std::move(sub_list));
132 base::DictionaryValue* sub_dict = new base::DictionaryValue(); 136 auto sub_dict = base::MakeUnique<base::DictionaryValue>();
133 sub_dict->SetInteger("1", 300); 137 sub_dict->SetInteger("1", 300);
134 sub_dict->Set("2", GinJavaBridgeValue::CreateObjectIDValue(3).release()); 138 sub_dict->Set("2", GinJavaBridgeValue::CreateObjectIDValue(3));
135 objects.Append(sub_dict); 139 objects.Append(std::move(sub_dict));
136 base::ListValue* sub_list_with_dict = new base::ListValue(); 140 auto sub_list_with_dict = base::MakeUnique<base::ListValue>();
137 base::DictionaryValue* sub_sub_dict = new base::DictionaryValue(); 141 auto sub_sub_dict = base::MakeUnique<base::DictionaryValue>();
138 sub_sub_dict->Set("1", GinJavaBridgeValue::CreateObjectIDValue(4).release()); 142 sub_sub_dict->Set("1", GinJavaBridgeValue::CreateObjectIDValue(4));
139 sub_list_with_dict->Append(sub_sub_dict); 143 sub_list_with_dict->Append(std::move(sub_sub_dict));
140 objects.Append(sub_list_with_dict); 144 objects.Append(std::move(sub_list_with_dict));
141 base::DictionaryValue* sub_dict_with_list = new base::DictionaryValue(); 145 auto sub_dict_with_list = base::MakeUnique<base::DictionaryValue>();
142 base::ListValue* sub_sub_list = new base::ListValue(); 146 auto sub_sub_list = base::MakeUnique<base::ListValue>();
143 sub_sub_list->Append(GinJavaBridgeValue::CreateObjectIDValue(5).release()); 147 sub_sub_list->Append(GinJavaBridgeValue::CreateObjectIDValue(5));
144 sub_dict_with_list->Set("1", sub_sub_list); 148 sub_dict_with_list->Set("1", std::move(sub_sub_list));
145 objects.Append(sub_dict_with_list); 149 objects.Append(std::move(sub_dict_with_list));
146 150
147 scoped_refptr<GinJavaMethodInvocationHelper> helper = 151 scoped_refptr<GinJavaMethodInvocationHelper> helper =
148 new GinJavaMethodInvocationHelper( 152 new GinJavaMethodInvocationHelper(
149 std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>( 153 std::unique_ptr<GinJavaMethodInvocationHelper::ObjectDelegate>(
150 new NullObjectDelegate()), 154 new NullObjectDelegate()),
151 "foo", objects); 155 "foo", objects);
152 CountingDispatcherDelegate counter; 156 CountingDispatcherDelegate counter;
153 helper->Init(&counter); 157 helper->Init(&counter);
154 counter.AssertInvocationsCount(1, 6); 158 counter.AssertInvocationsCount(1, 6);
155 } 159 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 helper->Invoke(); 328 helper->Invoke();
325 EXPECT_TRUE(object_delegate->find_method_called()); 329 EXPECT_TRUE(object_delegate->find_method_called());
326 EXPECT_TRUE(object_delegate->get_class_called()); 330 EXPECT_TRUE(object_delegate->get_class_called());
327 EXPECT_TRUE(helper->HoldsPrimitiveResult()); 331 EXPECT_TRUE(helper->HoldsPrimitiveResult());
328 EXPECT_TRUE(helper->GetPrimitiveResult().empty()); 332 EXPECT_TRUE(helper->GetPrimitiveResult().empty());
329 EXPECT_EQ(kGinJavaBridgeAccessToObjectGetClassIsBlocked, 333 EXPECT_EQ(kGinJavaBridgeAccessToObjectGetClassIsBlocked,
330 helper->GetInvocationError()); 334 helper->GetInvocationError());
331 } 335 }
332 336
333 } // namespace content 337 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698