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

Side by Side Diff: content/shell/browser/shell_mojo_test_utils_android.cc

Issue 1831173002: Scaffolding for Android implementation of PaymentRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo
Patch Set: Register PaymentRequest with render process Created 4 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/shell/browser/shell_mojo_test_utils_android.h" 5 #include "content/shell/browser/shell_mojo_test_utils_android.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "content/browser/mojo/service_registry_android.h"
13 #include "content/common/mojo/service_registry_impl.h" 12 #include "content/common/mojo/service_registry_impl.h"
14 #include "jni/ShellMojoTestUtils_jni.h" 13 #include "jni/ShellMojoTestUtils_jni.h"
15 14
16 namespace { 15 namespace {
17 16
18 struct TestEnvironment { 17 struct TestEnvironment {
19 base::MessageLoop message_loop; 18 base::MessageLoop message_loop;
20 ScopedVector<content::ServiceRegistryImpl> registries; 19 ScopedVector<content::ServiceRegistryImpl> registries;
21 ScopedVector<content::ServiceRegistryAndroid> wrappers;
22 }; 20 };
23 21
24 } // namespace 22 } // namespace
25 23
26 namespace content { 24 namespace content {
27 25
28 static jlong SetupTestEnvironment(JNIEnv* env, 26 static jlong SetupTestEnvironment(JNIEnv* env,
29 const JavaParamRef<jclass>& jcaller) { 27 const JavaParamRef<jclass>& jcaller) {
30 return reinterpret_cast<intptr_t>(new TestEnvironment()); 28 return reinterpret_cast<intptr_t>(new TestEnvironment());
31 } 29 }
(...skipping 17 matching lines...) Expand all
49 test_environment->registries.push_back(registry_b); 47 test_environment->registries.push_back(registry_b);
50 48
51 mojo::shell::mojom::InterfaceProviderPtr exposed_services_a; 49 mojo::shell::mojom::InterfaceProviderPtr exposed_services_a;
52 registry_a->Bind(GetProxy(&exposed_services_a)); 50 registry_a->Bind(GetProxy(&exposed_services_a));
53 registry_b->BindRemoteServiceProvider(std::move(exposed_services_a)); 51 registry_b->BindRemoteServiceProvider(std::move(exposed_services_a));
54 52
55 mojo::shell::mojom::InterfaceProviderPtr exposed_services_b; 53 mojo::shell::mojom::InterfaceProviderPtr exposed_services_b;
56 registry_b->Bind(GetProxy(&exposed_services_b)); 54 registry_b->Bind(GetProxy(&exposed_services_b));
57 registry_a->BindRemoteServiceProvider(std::move(exposed_services_b)); 55 registry_a->BindRemoteServiceProvider(std::move(exposed_services_b));
58 56
59 content::ServiceRegistryAndroid* wrapper_a = 57 return Java_ShellMojoTestUtils_makePair(env, registry_a->GetJavaObj().obj(),
60 new ServiceRegistryAndroid(registry_a); 58 registry_b->GetJavaObj().obj());
61 test_environment->wrappers.push_back(wrapper_a);
62 content::ServiceRegistryAndroid* wrapper_b =
63 new ServiceRegistryAndroid(registry_b);
64 test_environment->wrappers.push_back(wrapper_b);
65
66 return Java_ShellMojoTestUtils_makePair(env, wrapper_a->GetObj().obj(),
67 wrapper_b->GetObj().obj());
68 } 59 }
69 60
70 static void RunLoop(JNIEnv* env, 61 static void RunLoop(JNIEnv* env,
71 const JavaParamRef<jclass>& jcaller, 62 const JavaParamRef<jclass>& jcaller,
72 jlong timeout_ms) { 63 jlong timeout_ms) {
73 base::MessageLoop::current()->PostDelayedTask( 64 base::MessageLoop::current()->PostDelayedTask(
74 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 65 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(),
75 base::TimeDelta::FromMilliseconds(timeout_ms)); 66 base::TimeDelta::FromMilliseconds(timeout_ms));
76 base::RunLoop run_loop; 67 base::RunLoop run_loop;
77 run_loop.Run(); 68 run_loop.Run();
78 } 69 }
79 70
80 bool RegisterShellMojoTestUtils(JNIEnv* env) { 71 bool RegisterShellMojoTestUtils(JNIEnv* env) {
81 return RegisterNativesImpl(env); 72 return RegisterNativesImpl(env);
82 } 73 }
83 74
84 } // namespace content 75 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698