summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpvalenzuela <pvalenzuela@chromium.org>2015-08-25 11:44:01 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-25 18:44:52 +0000
commita715a2f88e842329e6133390788b6d8d22bf8201 (patch)
tree0b32bd5dff7e83544124a656961fbd31ee7ebe88
parent8fe06742be4a78023eae54d82e3e6fbde5bd864f (diff)
downloadchromium_src-a715a2f88e842329e6133390788b6d8d22bf8201.zip
chromium_src-a715a2f88e842329e6133390788b6d8d22bf8201.tar.gz
chromium_src-a715a2f88e842329e6133390788b6d8d22bf8201.tar.bz2
Convert ChromeSyncShell to use ChromePublic infrastructure (try #2)
This is a re-land of the patch originally committed as part of https://codereview.chromium.org/1282603005/. The one major change is that a landmine has been added to clobber the Android arm64 bot as it caused problems after the original commit. Several test fixes are included to support this change. Note: This CL only provides a GYP implementation (no GN). This is not a regression from the previous state. BUG=510211 Review URL: https://codereview.chromium.org/1305213003 Cr-Commit-Position: refs/heads/master@{#345392}
-rw-r--r--build/all.gyp4
-rwxr-xr-xbuild/get_landmines.py2
-rw-r--r--chrome/android/BUILD.gn69
-rw-r--r--chrome/android/chrome_apk.gyp182
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java1
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java2
-rw-r--r--chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc39
-rw-r--r--chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h25
-rw-r--r--chrome/android/sync_shell/java/AndroidManifest.xml.jinja2158
-rw-r--r--chrome/android/sync_shell/javatests/AndroidManifest.xml34
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java3
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java34
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java65
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java8
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java30
-rw-r--r--chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java2
-rw-r--r--chrome/browser/android/DEPS1
-rw-r--r--chrome/browser/android/chrome_sync_shell_main_delegate.cc24
-rw-r--r--chrome/browser/android/chrome_sync_shell_main_delegate.h25
-rw-r--r--chrome/browser/android/chrome_sync_shell_main_delegate_initializer.cc10
-rw-r--r--chrome/chrome_shell.gypi65
-rw-r--r--chrome/chrome_tests.gypi25
-rw-r--r--sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java4
-rw-r--r--sync/test/android/javatests/src/org/chromium/sync/test/util/MockSyncContentResolverDelegate.java3
24 files changed, 332 insertions, 483 deletions
diff --git a/build/all.gyp b/build/all.gyp
index b6f0a02..95d816f 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -87,8 +87,8 @@
'../android_webview/android_webview.gyp:system_webview_apk',
'../android_webview/android_webview_shell.gyp:android_webview_shell_apk',
'../chrome/android/chrome_apk.gyp:chrome_public_apk',
+ '../chrome/android/chrome_apk.gyp:chrome_sync_shell_apk',
'../chrome/chrome.gyp:chrome_shell_apk',
- '../chrome/chrome.gyp:chrome_sync_shell_apk',
'../remoting/remoting.gyp:remoting_apk',
],
}],
@@ -875,9 +875,9 @@
'../android_webview/android_webview.gyp:android_webview_test_apk',
'../android_webview/android_webview.gyp:android_webview_unittests_apk',
'../chrome/android/chrome_apk.gyp:chrome_public_test_apk',
+ '../chrome/android/chrome_apk.gyp:chrome_sync_shell_test_apk',
'../chrome/chrome.gyp:chrome_junit_tests',
'../chrome/chrome.gyp:chrome_shell_test_apk',
- '../chrome/chrome.gyp:chrome_sync_shell_test_apk',
'../chrome/chrome.gyp:chrome_uiautomator_tests',
'../chrome/chrome.gyp:chromedriver_webview_shell_apk',
'../chrome/chrome.gyp:unit_tests_apk',
diff --git a/build/get_landmines.py b/build/get_landmines.py
index 873563d..c1e07cc 100755
--- a/build/get_landmines.py
+++ b/build/get_landmines.py
@@ -75,6 +75,8 @@ def print_landmines():
print 'Clobber iOS to workaround Xcode deps bug (crbug.com/485435)'
if platform() == 'win':
print 'Clobber to delete stale generated files (crbug.com/510086)'
+ if platform() == 'android' and gyp_defines().get('target_arch') == 'arm64':
+ print 'Clobber to support new location/infra for chrome_sync_shell_apk'
def main():
diff --git a/chrome/android/BUILD.gn b/chrome/android/BUILD.gn
index 26c247a..67e7710 100644
--- a/chrome/android/BUILD.gn
+++ b/chrome/android/BUILD.gn
@@ -250,20 +250,6 @@ shared_library("chrome_shell") {
]
}
-# GYP: //chrome/chrome_shell.gypi:libchromesyncshell
-shared_library("chrome_sync_shell") {
- testonly = true
- sources = [
- #"shell/chrome_shell_entry_point.cc",
- #"sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc",
- #"sync_shell/chrome_main_delegate_chrome_sync_shell_android.h",
- ]
- deps = [
- "//sync:test_support_sync_fake_server_android",
- ]
- data_deps = [ ":chrome_shell_base" ]
-}
-
# GYP: N/A
android_resources("chrome_shell_resources") {
deps = [
@@ -411,33 +397,6 @@ android_apk("chrome_shell_apk") {
#},
}
-chrome_sync_shell_manifest =
- "$target_gen_dir/chrome_sync_shell_manifest/AndroidManifest.xml"
-
-# GYP: //chrome/chrome_shell.gypi:chrome_sync_shell_manifest
-jinja_template("chrome_sync_shell_manifest") {
- testonly = true
- input = "sync_shell/java/AndroidManifest.xml.jinja2"
- output = chrome_sync_shell_manifest
-}
-
-# GYP: //chrome/chrome_shell.gypi:chrome_sync_shell_apk
-android_apk("chrome_sync_shell_apk") {
- testonly = true
- deps = [
- ":chrome_shell_resources",
- ":chrome_shell_java",
- ":chrome_shell_assets",
- ":chrome_sync_shell",
- ":chrome_sync_shell_manifest",
- "//base:base_java",
- ]
- apk_name = "ChromeSyncShell"
- android_manifest = chrome_sync_shell_manifest
- native_libs = [ "libchrome_sync_shell.so" ]
- asset_location = chrome_shell_assets_dir
-}
-
# GYP: part of //chrome/chrome_tests.gypi:chrome_shell_test_apk
android_library("chrome_javatests") {
testonly = true
@@ -522,34 +481,6 @@ junit_binary("chrome_junit_tests") {
]
}
-# GYP: //chrome/chrome_tests.gypi:chrome_sync_shell_test_apk
-if (false) {
- # TODO(GYP): We need sync/sync_tests.gypi:test_support_sync_proto_java to be ported.
- # crbug.com/475612
- instrumentation_test_apk("chrome_sync_shell_test_apk") {
- apk_under_test = ":chrome_sync_shell_apk"
- deps = [
- ":chrome_java",
- ":chrome_shell_java",
- ":chrome_shell_test_java",
- "//base:base_java",
- "//base:base_java_test_support",
- "//chrome/test/android:chrome_java_test_support",
- "//components/invalidation/impl:java",
- "//content/public/android:content_java",
- "//content/public/test/android:content_java_test_support",
- "//sync/android:sync_java",
- "//sync:sync_java_test_support",
- "//third_party/android_tools:android_support_v13_java",
- "//third_party/android_tools:android_support_v7_appcompat_java",
- "//ui/android:ui_java",
- ]
- apk_name = "ChromeSyncShellTest"
- DEPRECATED_java_in_dir = "sync_shell/javatests/src"
- android_manifest = "sync_shell/javatests/AndroidManifest.xml"
- }
-}
-
# GYP: //chrome/chrome_tests.gypi:chrome_uiautomator_tests_java
android_library("chrome_uiautomator_tests_java") {
testonly = true
diff --git a/chrome/android/chrome_apk.gyp b/chrome/android/chrome_apk.gyp
index cb910ec..6e452b78 100644
--- a/chrome/android/chrome_apk.gyp
+++ b/chrome/android/chrome_apk.gyp
@@ -10,8 +10,11 @@
'chromium_code': 1,
'package_name': 'chrome_public_apk',
'manifest_package': 'org.chromium.chrome',
+ 'sync_shell_manifest_package': 'org.chromium.chrome.sync_shell',
'chrome_public_apk_manifest': '<(SHARED_INTERMEDIATE_DIR)/chrome_public_apk_manifest/AndroidManifest.xml',
'chrome_public_test_apk_manifest': '<(SHARED_INTERMEDIATE_DIR)/chrome_public_test_apk_manifest/AndroidManifest.xml',
+ 'chrome_sync_shell_apk_manifest': '<(SHARED_INTERMEDIATE_DIR)/chrome_sync_shell_apk_manifest/AndroidManifest.xml',
+ 'chrome_sync_shell_test_apk_manifest': '<(SHARED_INTERMEDIATE_DIR)/chrome_sync_shell_test_apk_manifest/AndroidManifest.xml',
# This list is shared with GN.
# Defines a list of source files should be present in the open-source
# chrome-apk but not in the published static_library which is included in the
@@ -60,23 +63,46 @@
'includes': [ '../../build/android/jinja_template.gypi' ],
},
{
- # GN: //chrome/android:chrome_public
- 'target_name': 'libchrome_public',
- 'type': 'shared_library',
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'chrome_sync_shell_template_resources',
+ 'type': 'none',
+ 'variables': {
+ 'jinja_inputs_base_dir': 'java/res_template',
+ 'jinja_inputs': [
+ '<(jinja_inputs_base_dir)/xml/searchable.xml',
+ '<(jinja_inputs_base_dir)/xml/syncadapter.xml',
+ ],
+ 'jinja_outputs_zip': '<(PRODUCT_DIR)/res.java/<(_target_name).zip',
+ 'jinja_variables': [
+ 'manifest_package=<(sync_shell_manifest_package)',
+ ],
+ },
+ 'all_dependent_settings': {
+ 'variables': {
+ 'additional_input_paths': ['<(jinja_outputs_zip)'],
+ 'dependencies_res_zip_paths': ['<(jinja_outputs_zip)'],
+ },
+ },
+ 'includes': [ '../../build/android/jinja_template.gypi' ],
+ },
+ {
+ # The base library used in both ChromePublic and ChromeSyncShell.
+ 'target_name': 'libchrome_public_base',
+ 'type': 'none',
'dependencies': [
'../../chrome/chrome.gyp:chrome_android_core',
],
'include_dirs': [
'../..',
],
- 'sources': [
- '<@(chrome_public_app_native_sources)',
- ],
- 'ldflags': [
- # Some android targets still depend on --gc-sections to link.
- # TODO: remove --gc-sections for Debug builds (crbug.com/159847).
- '-Wl,--gc-sections',
- ],
+ 'direct_dependent_settings': {
+ 'ldflags': [
+ # Some android targets still depend on --gc-sections to link.
+ # TODO: remove --gc-sections for Debug builds (crbug.com/159847).
+ '-Wl,--gc-sections',
+ ],
+ },
'conditions': [
# TODO(yfriedman): move this DEP to chrome_android_core to be shared
# between internal/external.
@@ -102,6 +128,34 @@
],
},
{
+ # GN: //chrome/android:chrome_public
+ 'target_name': 'libchrome_public',
+ 'type': 'shared_library',
+ 'sources': [
+ '<@(chrome_public_app_native_sources)',
+ ],
+ 'dependencies': [
+ 'libchrome_public_base',
+ ],
+ },
+ {
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'libchrome_sync_shell',
+ 'type': 'shared_library',
+ 'sources': [
+ '../browser/android/chrome_entry_point.cc',
+ '../browser/android/chrome_sync_shell_main_delegate_initializer.cc',
+ '../browser/android/chrome_sync_shell_main_delegate.h',
+ '../browser/android/chrome_sync_shell_main_delegate.cc',
+ ],
+ 'dependencies': [
+ 'libchrome_public_base',
+ '../../sync/sync.gyp:sync',
+ '../../sync/sync.gyp:test_support_sync_fake_server_android',
+ ],
+ },
+ {
# GN: //chrome/android:chrome_public_apk_manifest
'target_name': 'chrome_public_manifest',
'type': 'none',
@@ -119,6 +173,24 @@
'includes': [ '../../build/android/jinja_template.gypi' ],
},
{
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'chrome_sync_shell_manifest',
+ 'type': 'none',
+ 'variables': {
+ 'jinja_inputs': ['java/AndroidManifest.xml'],
+ 'jinja_output': '<(chrome_sync_shell_apk_manifest)',
+ 'jinja_variables': [
+ 'channel=<(android_channel)',
+ 'configuration_policy=<(configuration_policy)',
+ 'manifest_package=<(sync_shell_manifest_package)',
+ 'min_sdk_version=16',
+ 'target_sdk_version=22',
+ ],
+ },
+ 'includes': [ '../../build/android/jinja_template.gypi' ],
+ },
+ {
# GN: //chrome/android:chrome_public_apk
'target_name': 'chrome_public_apk',
'type': 'none',
@@ -157,6 +229,48 @@
'includes': [ '../../build/apk_fake_jar.gypi' ],
},
{
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'chrome_sync_shell_apk',
+ 'type': 'none',
+ 'variables': {
+ 'android_manifest_path': '<(chrome_sync_shell_apk_manifest)',
+ 'apk_name': 'ChromeSyncShell',
+ 'native_lib_target': 'libchrome_sync_shell',
+ 'java_in_dir': 'java',
+ 'conditions': [
+ # Only attempt loading the library from the APK for 64 bit devices
+ # until the number of 32 bit devices which don't support this
+ # approach falls to a minimal level - http://crbug.com/390618.
+ ['component != "shared_library" and profiling==0 and (target_arch == "arm64" or target_arch == "x86_64")', {
+ 'load_library_from_zip_file': '<(chrome_apk_load_library_from_zip)',
+ 'load_library_from_zip': '<(chrome_apk_load_library_from_zip)',
+ }],
+ ],
+ },
+ 'dependencies': [
+ 'chrome_android_paks_copy',
+ 'chrome_sync_shell_template_resources',
+ '../chrome.gyp:chrome_java',
+ # This exists here because com.google.protobuf.nano is needed in tests,
+ # but that code is stripped out via proguard. Adding this deps adds
+ # usages and prevents removal of the proto code.
+ '../../sync/sync.gyp:test_support_sync_proto_java',
+ ],
+ 'includes': [ 'chrome_apk.gypi' ],
+ },
+ {
+ # GN: N/A
+ # chrome_sync_shell_apk creates a .jar as a side effect. Any java targets
+ # that need that .jar in their classpath should depend on this target.
+ 'target_name': 'chrome_sync_shell_apk_java',
+ 'type': 'none',
+ 'dependencies': [
+ 'chrome_sync_shell_apk',
+ ],
+ 'includes': [ '../../build/apk_fake_jar.gypi' ],
+ },
+ {
# GN: //chrome/android:chrome_shared_test_java
# This target is for sharing tests between both upstream and internal
# trees until sufficient test coverage is upstream.
@@ -178,7 +292,6 @@
'../../net/net.gyp:net_java',
'../../net/net.gyp:net_java_test_support',
'../../sync/sync.gyp:sync_java_test_support',
- '../../sync/sync.gyp:sync_javatests',
'../../third_party/android_tools/android_tools.gyp:android_support_v7_appcompat_javalib',
'../../ui/android/ui_android.gyp:ui_javatests',
],
@@ -198,6 +311,20 @@
'includes': [ '../../build/android/jinja_template.gypi' ],
},
{
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'chrome_sync_shell_test_apk_manifest',
+ 'type': 'none',
+ 'variables': {
+ 'jinja_inputs': ['sync_shell/javatests/AndroidManifest.xml'],
+ 'jinja_output': '<(chrome_sync_shell_test_apk_manifest)',
+ 'jinja_variables': [
+ 'manifest_package=<(sync_shell_manifest_package)',
+ ],
+ },
+ 'includes': [ '../../build/android/jinja_template.gypi' ],
+ },
+ {
# GN: //chrome/android:chrome_public_test_apk
'target_name': 'chrome_public_test_apk',
'type': 'none',
@@ -222,6 +349,37 @@
'../../build/android/test_runner.gypi',
],
},
+ {
+ # TODO(pvalenzuela): Implement this target with GN:
+ # http://crbug.com/475612
+ 'target_name': 'chrome_sync_shell_test_apk',
+ 'type': 'none',
+ 'dependencies': [
+ 'chrome_sync_shell_apk_java',
+ '../../base/base.gyp:base_java',
+ '../../base/base.gyp:base_java_test_support',
+ '../../chrome/chrome.gyp:chrome_java',
+ '../../chrome/chrome.gyp:chrome_java_test_support',
+ '../../sync/sync.gyp:sync_java',
+ '../../sync/sync.gyp:sync_java_test_support',
+ '../../sync/sync.gyp:sync_javatests',
+ '../../sync/sync.gyp:test_support_sync_proto_java',
+ '../../testing/android/on_device_instrumentation.gyp:broker_java',
+ '../../testing/android/on_device_instrumentation.gyp:require_driver_apk',
+ ],
+ 'variables': {
+ 'android_manifest_path': '<(chrome_sync_shell_test_apk_manifest)',
+ 'package_name': 'chrome_sync_shell_test',
+ 'java_in_dir': 'sync_shell/javatests',
+ 'apk_name': 'ChromeSyncShellTest',
+ 'is_test_apk': 1,
+ 'test_type': 'instrumentation',
+ },
+ 'includes': [
+ '../../build/java_apk.gypi',
+ '../../build/android/test_runner.gypi',
+ ],
+ },
],
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
index 324dd7f..8fda10d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/ProfileSyncService.java
@@ -504,6 +504,7 @@ public class ProfileSyncService {
* is assumed that the Java caller has ownership of this pointer;
* ownership is transferred as part of this call.
*/
+ @VisibleForTesting
public void overrideNetworkResourcesForTest(long networkResources) {
nativeOverrideNetworkResourcesForTest(mNativeProfileSyncServiceAndroid, networkResources);
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java b/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
index ee14726..b48da08 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/sync/SyncController.java
@@ -10,6 +10,7 @@ import android.content.Context;
import android.util.Log;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.invalidation.InvalidationController;
import org.chromium.chrome.browser.signin.AccountManagementFragment;
@@ -99,6 +100,7 @@ public class SyncController implements ProfileSyncService.SyncStateChangedListen
* @param activity the current activity.
* @param accountName the full account name.
*/
+ @VisibleForTesting
public void signIn(Activity activity, String accountName) {
final Account account = AccountManagerHelper.createAccountFromName(accountName);
diff --git a/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc b/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc
deleted file mode 100644
index bcf45e5..0000000
--- a/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h"
-
-#include "base/android/jni_android.h"
-#include "base/android/jni_registrar.h"
-#include "sync/test/fake_server/android/fake_server_helper_android.h"
-
-ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() {
- return new ChromeMainDelegateChromeSyncShellAndroid();
-}
-
-ChromeMainDelegateChromeSyncShellAndroid::
-ChromeMainDelegateChromeSyncShellAndroid() {
-}
-
-ChromeMainDelegateChromeSyncShellAndroid::
-~ChromeMainDelegateChromeSyncShellAndroid() {
-}
-
-bool ChromeMainDelegateChromeSyncShellAndroid::BasicStartupComplete(
- int* exit_code) {
- return ChromeMainDelegateAndroid::BasicStartupComplete(exit_code);
-}
-
-int ChromeMainDelegateChromeSyncShellAndroid::RunProcess(
- const std::string& process_type,
- const content::MainFunctionParams& main_function_params) {
- if (process_type.empty()) {
- // This JNI registration can not be moved to JNI_OnLoad because
- // FakeServerHelper seems not known by class loader when shared library
- // is loaded.
- FakeServerHelperAndroid::Register(base::android::AttachCurrentThread());
- }
- return ChromeMainDelegateAndroid::RunProcess(process_type,
- main_function_params);
-}
diff --git a/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h b/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h
deleted file mode 100644
index 651a269..0000000
--- a/chrome/android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_ANDROID_SYNC_SHELL_CHROME_MAIN_DELEGATE_CHROME_SYNC_SHELL_ANDROID_H_
-#define CHROME_ANDROID_SYNC_SHELL_CHROME_MAIN_DELEGATE_CHROME_SYNC_SHELL_ANDROID_H_
-
-#include "chrome/app/android/chrome_main_delegate_android.h"
-
-class ChromeMainDelegateChromeSyncShellAndroid
- : public ChromeMainDelegateAndroid {
- public:
- ChromeMainDelegateChromeSyncShellAndroid();
- ~ChromeMainDelegateChromeSyncShellAndroid() override;
-
- bool BasicStartupComplete(int* exit_code) override;
- int RunProcess(
- const std::string& process_type,
- const content::MainFunctionParams& main_function_params) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ChromeMainDelegateChromeSyncShellAndroid);
-};
-
-#endif // CHROME_ANDROID_SYNC_SHELL_CHROME_MAIN_DELEGATE_CHROME_SYNC_SHELL_ANDROID_H_
diff --git a/chrome/android/sync_shell/java/AndroidManifest.xml.jinja2 b/chrome/android/sync_shell/java/AndroidManifest.xml.jinja2
deleted file mode 100644
index a706b8c..0000000
--- a/chrome/android/sync_shell/java/AndroidManifest.xml.jinja2
+++ /dev/null
@@ -1,158 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright 2014 The Chromium Authors. All rights reserved.
-
- Use of this source code is governed by a BSD-style license that can be
- found in the LICENSE file.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.chromium.chrome.sync_shell">
-
- <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
- <uses-permission android:name="android.permission.NFC"/>
- <uses-permission android:name="android.permission.RECORD_AUDIO"/>
- <uses-permission android:name="android.permission.VIBRATE"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
- <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
- <uses-permission android:name="android.permission.USE_CREDENTIALS" />
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <!-- Only Chrome can receive the messages and registration result for GCM -->
- <permission android:name="org.chromium.chrome.sync_shell.permission.C2D_MESSAGE"
- android:protectionLevel="signature" />
- <uses-permission android:name="org.chromium.chrome.sync_shell.permission.C2D_MESSAGE" />
- <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
-
- <application android:name="org.chromium.chrome.shell.ChromeShellApplication"
- android:icon="@mipmap/app_icon"
- android:label="Chrome Sync Shell">
- <activity android:name="org.chromium.chrome.shell.ChromeShellActivity"
- android:launchMode="singleTask"
- android:theme="@style/MainTheme"
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
- android:hardwareAccelerated="true">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity android:name="org.chromium.sync.test.util.MockGrantCredentialsPermissionActivity"
- android:exported="true">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- </intent-filter>
- </activity>
- <!-- The following service entries exist in order to allow us to
- start more than one sandboxed process. -->
-
- <!-- NOTE: If you change the values of "android:process" for any of the below services,
- you also need to update kHelperProcessExecutableName in chrome_constants.cc. -->
- {% set num_sandboxed_services = 20 %}
- <meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES"
- android:value="{{ num_sandboxed_services }}"/>
- {% for i in range(num_sandboxed_services) %}
- <service android:name="org.chromium.content.app.SandboxedProcessService{{ i }}"
- android:process=":sandboxed_process{{ i }}"
- android:isolatedProcess="true"
- android:exported="false" />
- {% endfor %}
-
- {% set num_privileged_services = 3 %}
- <meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES"
- android:value="{{ num_privileged_services }}"/>
- {% for i in range(num_privileged_services) %}
- <service android:name="org.chromium.content.app.PrivilegedProcessService{{ i }}"
- android:process=":privileged_process{{ i }}"
- android:isolatedProcess="false"
- android:exported="false" />
- {% endfor %}
-
- <!-- Receiver for GCM messages. Rebroadcasts them locally for sync. -->
- <receiver android:exported="true"
- android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener$GCMReceiver"
- android:permission="com.google.android.c2dm.permission.SEND">
- <intent-filter>
- <action android:name="com.google.android.c2dm.intent.RECEIVE" />
- <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
- <category android:name="org.chromium.chrome.shell"/>
- </intent-filter>
- </receiver>
- <service android:exported="false"
- android:name="com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener">
- <meta-data android:name="sender_ids"
- android:value="cloudprint.c2dm@gmail.com,ipc.invalidation@gmail.com"/>
- </service>
-
- <!-- Notification service for sync. -->
- <meta-data android:name="ipc.invalidation.ticl.listener_service_class"
- android:value="org.chromium.components.invalidation.InvalidationClientService"/>
- <service android:name="org.chromium.components.invalidation.InvalidationClientService"
- android:exported="false">
- <intent-filter>
- <action android:name="com.google.ipc.invalidation.AUTH_TOKEN_REQUEST"/>
- </intent-filter>
- </service>
- <service android:exported="false"
- android:name="com.google.ipc.invalidation.ticl.android2.TiclService"/>
- <service android:exported="false"
- android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageSenderService"/>
- <receiver android:exported="false"
- android:name="com.google.ipc.invalidation.ticl.android2.AndroidInternalScheduler$AlarmReceiver"/>
- <receiver android:exported="false"
- android:name="com.google.ipc.invalidation.external.client.contrib.AndroidListener$AlarmReceiver"/>
-
- <!-- Notification service multiplexed GCM receiver -->
- <service android:exported="false"
- android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService"
- android:enabled="true"/>
- <receiver android:exported="false"
- android:name="com.google.ipc.invalidation.ticl.android2.channel.AndroidMessageReceiverService$Receiver">
- <intent-filter>
- <action android:name="com.google.ipc.invalidation.gcmmplex.EVENT" />
- </intent-filter>
- </receiver>
-
- <!-- GCMDriver multiplexed GCM receiver -->
- <service android:exported="false"
- android:name="org.chromium.chrome.browser.services.gcm.GCMListener"/>
- <receiver android:exported="false"
- android:name="org.chromium.chrome.browser.services.gcm.GCMListener$Receiver">
- <intent-filter>
- <action android:name="com.google.ipc.invalidation.gcmmplex.EVENT" />
- </intent-filter>
- </receiver>
-
- <provider android:name="org.chromium.chrome.browser.ChromeBrowserProvider"
- android:authorities="org.chromium.chrome.sync_shell"
- android:exported="true" />
-
- <!-- Sync adapter for browser invalidation. -->
- <service android:exported="false"
- android:name="org.chromium.chrome.shell.invalidation.ChromeShellSyncAdapterService">
- <intent-filter>
- <action android:name="android.content.SyncAdapter" />
- </intent-filter>
- <meta-data android:name="android.content.SyncAdapter"
- android:resource="@xml/syncadapter" />
- </service>
-
- <!-- Broadcast receiver that will be notified of account changes. -->
- <receiver android:name="org.chromium.chrome.shell.signin.AccountsChangedReceiver">
- <intent-filter>
- <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" />
- </intent-filter>
- </receiver>
- <meta-data android:name="org.chromium.content.browser.SMART_CLIP_PROVIDER"
- android:value="org.chromium.content.browser.SmartClipProvider" />
-
- </application>
-</manifest>
diff --git a/chrome/android/sync_shell/javatests/AndroidManifest.xml b/chrome/android/sync_shell/javatests/AndroidManifest.xml
index 73d0790..eb83976 100644
--- a/chrome/android/sync_shell/javatests/AndroidManifest.xml
+++ b/chrome/android/sync_shell/javatests/AndroidManifest.xml
@@ -1,23 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
- <!-- Copyright (c) 2012 The Chromium Authors. All rights reserved. Use of
- this source code is governed by a BSD-style license that can be found
- in the LICENSE file. -->
- <!-- package name must be unique so suffix with "tests" so package loader
- doesn't ignore this. -->
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.chromium.chrome.sync_shell.tests">
- <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
- <uses-permission android:name="android.permission.RUN_INSTRUMENTATION" />
+<!-- Copyright 2015 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file. -->
+
+<!-- package name must be unique. -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.chromium.chrome.sync_shell.tests">
+ <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
- <!-- We add an application tag here just so that we can indicate that this
- package needs to link against the android.test library, which is
- needed when building test cases. -->
- <application>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.INTERNET" />
+
+ <application
+ android:label="ChromeSyncShellTest">
+
<uses-library android:name="android.test.runner" />
+
<activity android:name="org.chromium.sync.test.util.MockGrantCredentialsPermissionActivity"
- android:exported="false">
+ android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -25,6 +27,6 @@
</activity>
</application>
<instrumentation android:name="org.chromium.chrome.test.ChromeInstrumentationTestRunner"
- android:targetPackage="org.chromium.chrome.sync_shell"
- android:label="Tests for org.chromium.chrome.sync_shell"/>
+ android:targetPackage="{{manifest_package}}"
+ android:label="Tests for {{manifest_package}}"/>
</manifest>
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java
index 9b2cc38..e228ddf 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/FirstRunTest.java
@@ -9,7 +9,9 @@ import android.os.Bundle;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.firstrun.FirstRunActivity;
import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
@@ -18,6 +20,7 @@ import org.chromium.sync.AndroidSyncSettings;
/**
* Tests for the first run experience.
*/
+@CommandLineFlags.Remove(ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE)
public class FirstRunTest extends SyncTestBase {
private static final String TAG = "FirstRunTest";
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
index 9951b85..e164db3 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/OpenTabsTest.java
@@ -9,6 +9,7 @@ import android.util.Pair;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.tabmodel.TabModelUtils;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -89,8 +90,8 @@ public class OpenTabsTest extends SyncTestBase {
@Feature({"Sync"})
public void testUploadMultipleOpenTabs() throws Exception {
loadUrl(URL);
- openNewTab(URL2);
- openNewTab(URL3);
+ loadUrlInNewTab(URL2);
+ loadUrlInNewTab(URL3);
waitForLocalTabsForClient(mClientName, URL, URL2, URL3);
waitForServerTabs(URL, URL2, URL3);
}
@@ -101,10 +102,17 @@ public class OpenTabsTest extends SyncTestBase {
public void testUploadAndCloseOpenTab() throws Exception {
loadUrl(URL);
// Can't have zero tabs, so we have to open two to test closing one.
- openNewTab(URL2);
+ loadUrlInNewTab(URL2);
waitForLocalTabsForClient(mClientName, URL, URL2);
waitForServerTabs(URL, URL2);
- closeActiveTab();
+
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ assertTrue(TabModelUtils.closeCurrentTab(getActivity().getCurrentTabModel()));
+ }
+ });
+
waitForLocalTabsForClient(mClientName, URL);
waitForServerTabs(URL);
}
@@ -169,24 +177,6 @@ public class OpenTabsTest extends SyncTestBase {
waitForLocalTabsForClient(FAKE_CLIENT);
}
- private void openNewTab(final String url) {
- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
- @Override
- public void run() {
- getActivity().createTab(url);
- }
- });
- }
-
- private void closeActiveTab() {
- ThreadUtils.runOnUiThreadBlocking(new Runnable() {
- @Override
- public void run() {
- getActivity().closeTab();
- }
- });
- }
-
private String makeSessionTag() {
return SESSION_TAG_PREFIX + (mSessionTagCounter++);
}
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java
index 11b7b53..3335ed5 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncCustomizationFragmentTest.java
@@ -5,30 +5,30 @@
package org.chromium.chrome.browser.sync;
import android.annotation.SuppressLint;
-import android.app.Activity;
import android.app.Dialog;
import android.app.FragmentTransaction;
import android.content.Context;
-import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.SwitchPreference;
import android.preference.TwoStatePreference;
import android.support.v7.app.AlertDialog;
import android.test.suitebuilder.annotation.SmallTest;
-import android.view.View;
import android.widget.Button;
+import android.widget.CheckedTextView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.R;
+import org.chromium.chrome.browser.preferences.Preferences;
import org.chromium.chrome.browser.sync.ui.PassphraseCreationDialogFragment;
import org.chromium.chrome.browser.sync.ui.PassphraseDialogFragment;
import org.chromium.chrome.browser.sync.ui.PassphraseTypeDialogFragment;
import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment;
-import org.chromium.chrome.shell.R;
+import org.chromium.chrome.test.util.ActivityUtils;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
@@ -88,12 +88,12 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
SyncCustomizationFragment.PREFERENCE_SYNC_SETTINGS);
}
- private Activity mActivity;
+ private Preferences mPreferences;
@Override
protected void setUp() throws Exception {
super.setUp();
- mActivity = getActivity();
+ mPreferences = null;
}
@SmallTest
@@ -236,7 +236,7 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
public void testDefaultEncryptionOptions() throws Exception {
setupTestAccountAndSignInToSync(CLIENT_ID);
SyncTestUtil.waitForSyncActive(mContext);
- SyncCustomizationFragment fragment = startSyncCustomizationFragment();
+ final SyncCustomizationFragment fragment = startSyncCustomizationFragment();
Preference encryption = getEncryption(fragment);
clickPreference(encryption);
@@ -250,12 +250,14 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
assertEquals(PassphraseType.CUSTOM_PASSPHRASE, adapter.getType(0));
assertEquals(PassphraseType.KEYSTORE_PASSPHRASE, adapter.getType(1));
assertEquals(2, listView.getCount());
- // Make sure they are both enabled and the correct on is selected.
- View customView = listView.getChildAt(0);
- View keystoreView = listView.getChildAt(1);
- assertTrue(customView.isEnabled());
- assertTrue(keystoreView.isEnabled());
- assertEquals(keystoreView, listView.getSelectedView());
+
+ // Make sure they are both enabled and the correct one is selected.
+ CheckedTextView customView = (CheckedTextView) listView.getChildAt(0);
+ CheckedTextView keystoreView = (CheckedTextView) listView.getChildAt(1);
+ assertTrue("The custom passphrase view should be enabled.", customView.isEnabled());
+ assertFalse("The custom passphrase option should be checked.", customView.isChecked());
+ assertTrue("The keystore passphrase view should be enabled.", keystoreView.isEnabled());
+ assertTrue("The keystore passphrase option should be checked.", keystoreView.isChecked());
}
/**
@@ -332,8 +334,9 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
public void run() {
pss.syncStateChanged();
fragment.getFragmentManager().executePendingTransactions();
- PassphraseDialogFragment passphraseFragment = getPassphraseDialogFragment();
- assertNull(passphraseFragment);
+ assertNull("PassphraseDialogFragment should be dismissed.",
+ mPreferences.getFragmentManager().findFragmentByTag(
+ SyncCustomizationFragment.FRAGMENT_ENTER_PASSPHRASE));
}
});
}
@@ -409,20 +412,13 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
}
private SyncCustomizationFragment startSyncCustomizationFragment() {
- SyncCustomizationFragment fragment = new SyncCustomizationFragment();
- Bundle args = new Bundle();
- args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT,
- SyncTestUtil.DEFAULT_TEST_ACCOUNT);
- fragment.setArguments(args);
- FragmentTransaction transaction = mActivity.getFragmentManager().beginTransaction();
- transaction.add(R.id.content_container, fragment, TAG);
- transaction.commit();
+ mPreferences = startPreferences(SyncCustomizationFragment.class.getName());
getInstrumentation().waitForIdleSync();
- return fragment;
+ return (SyncCustomizationFragment) mPreferences.getFragmentForTest();
}
private void closeFragment(SyncCustomizationFragment fragment) {
- FragmentTransaction transaction = mActivity.getFragmentManager().beginTransaction();
+ FragmentTransaction transaction = mPreferences.getFragmentManager().beginTransaction();
transaction.remove(fragment);
transaction.commit();
getInstrumentation().waitForIdleSync();
@@ -459,19 +455,22 @@ public class SyncCustomizationFragmentTest extends SyncTestBase {
SyncCustomizationFragment.PREFERENCE_SYNC_MANAGE_DATA);
}
- private PassphraseDialogFragment getPassphraseDialogFragment() {
- return (PassphraseDialogFragment) mActivity.getFragmentManager().findFragmentByTag(
+ private PassphraseDialogFragment getPassphraseDialogFragment()
+ throws InterruptedException {
+ return ActivityUtils.<PassphraseDialogFragment>waitForFragment(mPreferences,
SyncCustomizationFragment.FRAGMENT_ENTER_PASSPHRASE);
}
- private PassphraseTypeDialogFragment getPassphraseTypeDialogFragment() {
- return (PassphraseTypeDialogFragment) mActivity.getFragmentManager()
- .findFragmentByTag(SyncCustomizationFragment.FRAGMENT_PASSPHRASE_TYPE);
+ private PassphraseTypeDialogFragment getPassphraseTypeDialogFragment()
+ throws InterruptedException {
+ return ActivityUtils.<PassphraseTypeDialogFragment>waitForFragment(mPreferences,
+ SyncCustomizationFragment.FRAGMENT_PASSPHRASE_TYPE);
}
- private PassphraseCreationDialogFragment getPassphraseCreationDialogFragment() {
- return (PassphraseCreationDialogFragment) mActivity.getFragmentManager()
- .findFragmentByTag(SyncCustomizationFragment.FRAGMENT_CUSTOM_PASSPHRASE);
+ private PassphraseCreationDialogFragment getPassphraseCreationDialogFragment()
+ throws InterruptedException {
+ return ActivityUtils.<PassphraseCreationDialogFragment>waitForFragment(mPreferences,
+ SyncCustomizationFragment.FRAGMENT_CUSTOM_PASSPHRASE);
}
private void assertDefaultSyncOnState(SyncCustomizationFragment fragment) {
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
index fcf500f..1b1c64c 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTest.java
@@ -12,7 +12,7 @@ import android.util.Log;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.test.util.Feature;
-import org.chromium.chrome.shell.ChromeShellActivity;
+import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.Criteria;
@@ -80,7 +80,7 @@ public class SyncTest extends SyncTestBase {
public void testAboutSyncPageDisplaysCurrentSyncStatus() throws InterruptedException {
setupTestAccountAndSignInToSync(CLIENT_ID);
- loadUrlWithSanitization("chrome://sync");
+ loadUrl("chrome://sync");
SyncTestUtil.AboutSyncInfoGetter aboutInfoGetter =
new SyncTestUtil.AboutSyncInfoGetter(getActivity());
try {
@@ -169,7 +169,7 @@ public class SyncTest extends SyncTestBase {
SyncTestUtil.verifySyncIsActiveForAccount(mContext, account);
}
- private static ContentViewCore getContentViewCore(ChromeShellActivity activity) {
- return activity.getActiveContentViewCore();
+ private static ContentViewCore getContentViewCore(ChromeActivity activity) {
+ return activity.getActivityTab().getContentViewCore();
}
}
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java
index 24b7bc5..e5e3987 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/SyncTestBase.java
@@ -8,12 +8,13 @@ import android.accounts.Account;
import android.content.Context;
import org.chromium.base.ThreadUtils;
+import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.identity.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.identity.UniqueIdentificationGeneratorFactory;
import org.chromium.chrome.browser.identity.UuidBasedUniqueIdentificationGenerator;
import org.chromium.chrome.browser.signin.AccountIdProvider;
import org.chromium.chrome.browser.signin.SigninManager;
-import org.chromium.chrome.shell.ChromeShellTestBase;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
import org.chromium.chrome.test.util.browser.sync.SyncTestUtil;
import org.chromium.sync.AndroidSyncSettings;
import org.chromium.sync.signin.AccountManagerHelper;
@@ -26,7 +27,7 @@ import java.util.Set;
/**
* Base class for common functionality between sync tests.
*/
-public class SyncTestBase extends ChromeShellTestBase {
+public class SyncTestBase extends ChromeActivityTestCaseBase<ChromeActivity> {
private static final String TAG = "SyncTestBase";
protected static final String CLIENT_ID = "Client_ID";
@@ -38,21 +39,33 @@ public class SyncTestBase extends ChromeShellTestBase {
protected ProfileSyncService mProfileSyncService;
protected MockSyncContentResolverDelegate mSyncContentResolver;
+ public SyncTestBase() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ // Start the activity by opening about:blank. This URL is ideal because it is not synced as
+ // a typed URL. If another URL is used, it could interfere with test data.
+ startMainActivityOnBlankPage();
+ }
+
@Override
protected void setUp() throws Exception {
+ // This must be called before super.setUp() in order for test authentication to work
+ // properly.
+ mapAccountNamesToIds();
+
super.setUp();
- assertTrue("Clearing app data failed.", clearAppData());
Context targetContext = getInstrumentation().getTargetContext();
mContext = new SyncTestUtil.SyncTestContext(targetContext);
- mapAccountNamesToIds();
setUpMockAndroidSyncSettings();
setUpMockAccountManager();
// Initializes ChromeSigninController to use our test context.
ChromeSigninController.get(mContext);
- startChromeBrowserProcessSync(targetContext);
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
@@ -69,13 +82,6 @@ public class SyncTestBase extends ChromeShellTestBase {
mProfileSyncService = ProfileSyncService.get(mContext);
}
});
-
- // Start the activity by opening about:blank. This URL is ideal because it is not synced as
- // a typed URL. If another URL is used, it could interfere with test data. This call is in
- // this location so that it takes place before any other calls to getActivity(). If
- // getActivity() is called without any prior configuration, an undesired URL
- // (e.g., google.com) will be opened.
- launchChromeShellWithBlankPage();
}
@Override
diff --git a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java
index abad5bb..248d7b0 100644
--- a/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java
+++ b/chrome/android/sync_shell/javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java
@@ -104,7 +104,7 @@ public class TypedUrlsTest extends SyncTestBase {
@Override
public void run() {
LoadUrlParams params = new LoadUrlParams(url, PageTransition.TYPED);
- getActivity().getActiveTab().loadUrl(params);
+ getActivity().getActivityTab().loadUrl(params);
}
});
}
diff --git a/chrome/browser/android/DEPS b/chrome/browser/android/DEPS
index 4dc31ea..5894717 100644
--- a/chrome/browser/android/DEPS
+++ b/chrome/browser/android/DEPS
@@ -8,4 +8,5 @@ include_rules = [
"+cc/layers/layer.h",
"+sandbox/linux/seccomp-bpf/sandbox_bpf.h",
"+sync/android",
+ "+sync/test/fake_server/android",
]
diff --git a/chrome/browser/android/chrome_sync_shell_main_delegate.cc b/chrome/browser/android/chrome_sync_shell_main_delegate.cc
new file mode 100644
index 0000000..b5bc9ed
--- /dev/null
+++ b/chrome/browser/android/chrome_sync_shell_main_delegate.cc
@@ -0,0 +1,24 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/chrome_sync_shell_main_delegate.h"
+
+#include "base/android/jni_android.h"
+#include "sync/test/fake_server/android/fake_server_helper_android.h"
+
+ChromeSyncShellMainDelegate::ChromeSyncShellMainDelegate() {
+}
+
+ChromeSyncShellMainDelegate::~ChromeSyncShellMainDelegate() {
+}
+
+int ChromeSyncShellMainDelegate::RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) {
+ if (process_type.empty()) {
+ FakeServerHelperAndroid::Register(base::android::AttachCurrentThread());
+ }
+ return ChromeMainDelegateStagingAndroid::RunProcess(
+ process_type, main_function_params);
+}
diff --git a/chrome/browser/android/chrome_sync_shell_main_delegate.h b/chrome/browser/android/chrome_sync_shell_main_delegate.h
new file mode 100644
index 0000000..c4d2d88
--- /dev/null
+++ b/chrome/browser/android/chrome_sync_shell_main_delegate.h
@@ -0,0 +1,25 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_ANDROID_CHROME_SYNC_SHELL_MAIN_DELEGATE_H_
+#define CHROME_BROWSER_ANDROID_CHROME_SYNC_SHELL_MAIN_DELEGATE_H_
+
+#include "chrome/browser/android/chrome_main_delegate_staging_android.h"
+
+class ChromeSyncShellMainDelegate
+ : public ChromeMainDelegateStagingAndroid {
+ public:
+ ChromeSyncShellMainDelegate();
+ ~ChromeSyncShellMainDelegate() override;
+
+ protected:
+ int RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) override;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeSyncShellMainDelegate);
+};
+
+#endif // CHROME_BROWSER_ANDROID_CHROME_SYNC_SHELL_MAIN_DELEGATE_H_
diff --git a/chrome/browser/android/chrome_sync_shell_main_delegate_initializer.cc b/chrome/browser/android/chrome_sync_shell_main_delegate_initializer.cc
new file mode 100644
index 0000000..b7c0da6
--- /dev/null
+++ b/chrome/browser/android/chrome_sync_shell_main_delegate_initializer.cc
@@ -0,0 +1,10 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/app/android/chrome_main_delegate_android.h"
+#include "chrome/browser/android/chrome_sync_shell_main_delegate.h"
+
+ChromeMainDelegateAndroid* ChromeMainDelegateAndroid::Create() {
+ return new ChromeSyncShellMainDelegate();
+}
diff --git a/chrome/chrome_shell.gypi b/chrome/chrome_shell.gypi
index 7e2e8f5..b48a169 100644
--- a/chrome/chrome_shell.gypi
+++ b/chrome/chrome_shell.gypi
@@ -57,21 +57,6 @@
],
},
{
- # GN: //chrome/android:chrome_sync_shell
- 'target_name': 'libchromesyncshell',
- 'type': 'shared_library',
- 'sources': [
- 'android/shell/chrome_shell_entry_point.cc',
- 'android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.cc',
- 'android/sync_shell/chrome_main_delegate_chrome_sync_shell_android.h',
- ],
- 'dependencies': [
- 'libchromeshell_base',
- '../sync/sync.gyp:sync_core',
- '../sync/sync.gyp:test_support_sync_fake_server_android',
- ],
- },
- {
# GN: //chrome/android:chrome_shell_manifest
'target_name': 'chrome_shell_manifest',
'type': 'none',
@@ -122,56 +107,6 @@
],
'includes': [ '../build/apk_fake_jar.gypi' ],
},
- {
- # GN: //chrome/android:chrome_sync_shell_manifest
- 'target_name': 'chrome_sync_shell_manifest',
- 'type': 'none',
- 'variables': {
- 'jinja_inputs': ['android/sync_shell/java/AndroidManifest.xml.jinja2'],
- 'jinja_output': '<(SHARED_INTERMEDIATE_DIR)/chrome_sync_shell_manifest/AndroidManifest.xml',
- },
- 'includes': [ '../build/android/jinja_template.gypi' ],
- },
- {
- # GN: //chrome/android:chrome_sync_shell_apk
- 'target_name': 'chrome_sync_shell_apk',
- 'type': 'none',
- 'dependencies': [
- 'chrome_java',
- 'chrome_android_paks_copy',
- 'libchromesyncshell',
- '../media/media.gyp:media_java',
- '../sync/sync.gyp:sync_java_test_support',
- ],
- 'variables': {
- 'apk_name': 'ChromeSyncShell',
- 'android_manifest_path': '<(SHARED_INTERMEDIATE_DIR)/chrome_sync_shell_manifest/AndroidManifest.xml',
- 'R_package': 'org.chromium.chrome.shell',
- 'native_lib_version_name': '<(version_full)',
- 'java_in_dir': 'android/shell/java',
- 'resource_dir': 'android/shell/res',
- 'asset_location': '<(PRODUCT_DIR)/assets/<(package_name)',
- 'native_lib_target': 'libchromesyncshell',
- 'additional_input_paths': [
- '<@(chrome_android_pak_output_resources)',
- ],
- },
- 'includes': [ '../build/java_apk.gypi', ],
- },
- {
- # GN: N/A
- # chrome_sync_shell_apk creates a .jar as a side effect. Any java
- # targets that need that .jar in their classpath should depend on this
- # target. Dependents of chrome_sync_shell_apk receive its jar path in the
- # variable 'apk_output_jar_path'. This target should only be used by
- # targets which instrument chrome_sync_shell_apk.
- 'target_name': 'chrome_sync_shell_apk_java',
- 'type': 'none',
- 'dependencies': [
- 'chrome_sync_shell_apk',
- ],
- 'includes': [ '../build/apk_fake_jar.gypi' ],
- },
],
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index a45ac41..9348234 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -3092,31 +3092,6 @@
'includes': [ '../build/uiautomator_test.gypi' ],
},
{
- # GN: //chrome/android:chrome_sync_shell_test_apk
- 'target_name': 'chrome_sync_shell_test_apk',
- 'type': 'none',
- 'dependencies': [
- 'chrome_java',
- 'chrome_sync_shell_apk_java',
- 'chrome_java_test_support',
- '../base/base.gyp:base',
- '../base/base.gyp:base_java_test_support',
- '../content/content_shell_and_tests.gyp:content_java_test_support',
- '../sync/sync.gyp:test_support_sync_proto_java',
- ],
- 'variables': {
- 'apk_name': 'ChromeSyncShellTest',
- 'java_in_dir': 'android/sync_shell/javatests',
- 'additional_src_dirs': [ 'android/shell/javatests', ],
- 'is_test_apk': 1,
- 'test_type': 'instrumentation',
- },
- 'includes': [
- '../build/java_apk.gypi',
- '../build/android/test_runner.gypi',
- ],
- },
- {
# GN: //chrome/test/android:chrome_java_test_support
'target_name': 'chrome_java_test_support',
'type': 'none',
diff --git a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
index a9f8239..532abe1 100644
--- a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
+++ b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockAccountManager.java
@@ -27,6 +27,7 @@ import android.os.Handler;
import android.text.TextUtils;
import org.chromium.base.Log;
+import org.chromium.base.VisibleForTesting;
import org.chromium.sync.signin.AccountManagerDelegate;
import org.chromium.sync.signin.AccountManagerHelper;
@@ -88,6 +89,7 @@ public class MockAccountManager implements AccountManagerDelegate {
private final SingleThreadedExecutor mExecutor;
+ @VisibleForTesting
public MockAccountManager(Context context, Context testContext, Account... accounts) {
mContext = context;
// The manifest that is backing testContext needs to provide the
@@ -134,6 +136,7 @@ public class MockAccountManager implements AccountManagerDelegate {
}
}
+ @VisibleForTesting
public boolean addAccountHolderExplicitly(AccountHolder accountHolder) {
return addAccountHolderExplicitly(accountHolder, false);
}
@@ -154,6 +157,7 @@ public class MockAccountManager implements AccountManagerDelegate {
return result;
}
+ @VisibleForTesting
public boolean removeAccountHolderExplicitly(AccountHolder accountHolder) {
return removeAccountHolderExplicitly(accountHolder, false);
}
diff --git a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockSyncContentResolverDelegate.java b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockSyncContentResolverDelegate.java
index b467d26..26b9db5 100644
--- a/sync/test/android/javatests/src/org/chromium/sync/test/util/MockSyncContentResolverDelegate.java
+++ b/sync/test/android/javatests/src/org/chromium/sync/test/util/MockSyncContentResolverDelegate.java
@@ -14,6 +14,7 @@ import android.os.Bundle;
import junit.framework.Assert;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.sync.SyncContentResolverDelegate;
import java.util.HashMap;
@@ -70,6 +71,7 @@ public class MockSyncContentResolverDelegate implements SyncContentResolverDeleg
}
@Override
+ @VisibleForTesting
public void setMasterSyncAutomatically(boolean sync) {
if (mMasterSyncAutomatically == sync) return;
@@ -170,6 +172,7 @@ public class MockSyncContentResolverDelegate implements SyncContentResolverDeleg
*
* @throws InterruptedException
*/
+ @VisibleForTesting
public void waitForLastNotificationCompleted() throws InterruptedException {
Assert.assertTrue("Timed out waiting for notifications to complete.",
mPendingObserverCount.tryAcquire(5, TimeUnit.SECONDS));