Add experimental Android browser test

Add some brave tests

Format files
This commit is contained in:
wchen342
2021-06-16 18:21:54 +03:00
parent 6fd2784694
commit 53367b3280
17 changed files with 466 additions and 132 deletions
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2021 The Brave 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"
xmlns:tools="http://schemas.android.com/tools"
package="org.chromium.android_browsertests_apk">
<uses-feature android:glEsVersion="0x00020000" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
<application android:name="ChromeBrowserTestsApplication"
android:label="ChromeBrowserTests"
android:requestLegacyExternalStorage="true">
<activity android:name="ChromeBrowserTestsActivity"
android:launchMode="singleTask"
android:theme="@style/Theme.Chromium.TabbedMode"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize"
android:hardwareAccelerated="true"
android:process=":test_process">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="org.chromium.chrome.browser.media.MediaLauncherActivity"
android:theme="@android:style/Theme.NoDisplay"
android:excludeFromRecents="true"
android:exported="true"
android:enabled="false"><!-- This will be selectively enabled at runtime. -->
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<!-- TODO(https://crbug.com/800875): Limit these to
supported MIME types. -->
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:scheme="file" />
<data android:scheme="content" />
</intent-filter>
</activity>
<activity-alias android:name="org.chromium.chrome.browser.media.AudioLauncherActivity"
android:targetActivity="org.chromium.chrome.browser.media.MediaLauncherActivity"
android:theme="@android:style/Theme.NoDisplay"
android:excludeFromRecents="true"
android:exported="true"
android:enabled="false"><!-- This will be selectively enabled at runtime. -->
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<!-- TODO(https://crbug.com/800875): Limit these to supported MIME types. -->
<data android:mimeType="audio/*" />
<data android:scheme="file" />
<data android:scheme="content" />
</intent-filter>
</activity-alias>
<activity android:name="org.chromium.chrome.browser.incognito.IncognitoTabLauncher"
android:theme="@android:style/Theme.NoDisplay"
android:taskAffinity=""
android:enabled="false"
android:excludeFromRecents="true"
android:exported="true">
<intent-filter>
<action android:name="org.chromium.chrome.browser.incognito.OPEN_PRIVATE_TAB" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="org.chromium.chrome.browser.sharing.shared_clipboard.SharedClipboardShareActivity"
android:icon="@drawable/ic_devices_48dp"
android:label="@string/shared_clipboard_share_activity_title"
android:enabled="false"
android:excludeFromRecents="true"
android:exported="true"
android:noHistory="true"
android:theme="@style/Theme.Chromium.Activity.TranslucentNoAnimations"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|mcc|mnc|screenLayout|smallestScreenSize" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<service android:name="org.chromium.components.background_task_scheduler.BackgroundTaskJobService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"/>
<service android:name="org.chromium.chrome.browser.crash.ChromeMinidumpUploadJobService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="false"/>
<!-- 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 = 40 %}
<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 = 5 %}
<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 %}
{% include "//brave/android/java/AndroidManifest.xml" %}
</application>
<instrumentation android:name="org.chromium.android_browsertests_apk.ChromeBrowserTestsInstrumentationTestRunner"
android:label="ChromeBrowserTests"
android:targetPackage="org.chromium.android_browsertests_apk"
chromium-junit3="true"/>
</manifest>
@@ -22,7 +22,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import org.chromium.base.Log;
import org.chromium.chrome.R;
+37 -31
View File
@@ -4,13 +4,9 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "chrome/browser/domain_reliability/service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/embedder_support/switches.h"
@@ -31,7 +27,15 @@
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
using BraveMainDelegateBrowserTest = InProcessBrowserTest;
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/browser/ui/profile_picker.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#endif
using BraveMainDelegateBrowserTest = PlatformBrowserTest;
const char kBraveOriginTrialsPublicKey[] =
"bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld9Mw3E=,"
@@ -49,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisableHyperlinkAuditing) {
EXPECT_TRUE(
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoPings));
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
chrome_test_utils::GetActiveWebContents(this);
const blink::web_pref::WebPreferences prefs =
contents->GetOrCreateWebPreferences();
EXPECT_FALSE(prefs.hyperlink_auditing_enabled);
@@ -65,30 +69,32 @@ IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, OriginTrialsTest) {
IN_PROC_BROWSER_TEST_F(BraveMainDelegateBrowserTest, DisabledFeatures) {
const base::Feature* disabled_features[] = {
&autofill::features::kAutofillEnableAccountWalletStorage,
&autofill::features::kAutofillServerCommunication,
&blink::features::kFledgeInterestGroupAPI,
&blink::features::kFledgeInterestGroups,
&blink::features::kHandwritingRecognitionWebPlatformApi,
&blink::features::kHandwritingRecognitionWebPlatformApiFinch,
&blink::features::kInterestCohortAPIOriginTrial,
&blink::features::kInterestCohortFeaturePolicy,
&blink::features::kTextFragmentAnchor,
&features::kDirectSockets,
&features::kIdleDetection,
&features::kLangClientHintHeader,
&features::kNotificationTriggers,
&features::kSignedExchangePrefetchCacheForNavigations,
&features::kSignedExchangeSubresourcePrefetch,
&features::kSubresourceWebBundles,
&features::kWebOTP,
&federated_learning::kFederatedLearningOfCohorts,
&federated_learning::kFlocIdComputedEventLogging,
&kEnableProfilePickerOnStartupFeature,
&media::kLiveCaption,
&net::features::kFirstPartySets,
&network::features::kTrustTokens,
&network_time::kNetworkTimeServiceQuerying,
&autofill::features::kAutofillEnableAccountWalletStorage,
&autofill::features::kAutofillServerCommunication,
&blink::features::kFledgeInterestGroupAPI,
&blink::features::kFledgeInterestGroups,
&blink::features::kHandwritingRecognitionWebPlatformApi,
&blink::features::kHandwritingRecognitionWebPlatformApiFinch,
&blink::features::kInterestCohortAPIOriginTrial,
&blink::features::kInterestCohortFeaturePolicy,
&blink::features::kTextFragmentAnchor,
&features::kDirectSockets,
&features::kIdleDetection,
&features::kLangClientHintHeader,
&features::kNotificationTriggers,
&features::kSignedExchangePrefetchCacheForNavigations,
&features::kSignedExchangeSubresourcePrefetch,
&features::kSubresourceWebBundles,
&features::kWebOTP,
&federated_learning::kFederatedLearningOfCohorts,
&federated_learning::kFlocIdComputedEventLogging,
#if !defined(OS_ANDROID)
&kEnableProfilePickerOnStartupFeature,
#endif
&media::kLiveCaption,
&net::features::kFirstPartySets,
&network::features::kTrustTokens,
&network_time::kNetworkTimeServiceQuerying,
};
for (const auto* feature : disabled_features)
@@ -5,10 +5,15 @@
#include "brave/common/brave_switches.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
class BraveMainDelegateRuntimeFlagsBrowserTest : public InProcessBrowserTest {
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
class BraveMainDelegateRuntimeFlagsBrowserTest : public PlatformBrowserTest {
public:
BraveMainDelegateRuntimeFlagsBrowserTest() {}
~BraveMainDelegateRuntimeFlagsBrowserTest() override {}
@@ -480,8 +480,7 @@ void JNI_BravePrefServiceBridge_SetP3AEnabled(
g_browser_process->local_state()->CommitPendingWrite();
}
jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(
JNIEnv* env) {
static jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(JNIEnv* env) {
return g_browser_process->local_state()->GetBoolean(
brave::kP3AEnabled);
}
@@ -508,7 +507,7 @@ jboolean JNI_BravePrefServiceBridge_GetP3ANoticeAcknowledged(
void JNI_BravePrefServiceBridge_SetP3AEnabled(JNIEnv* env, jboolean value) {}
jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(JNIEnv* env) {
static jboolean JNI_BravePrefServiceBridge_GetP3AEnabled(JNIEnv* env) {
return false;
}
+71 -56
View File
@@ -13,9 +13,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/embedder_support/pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
@@ -42,103 +41,119 @@
#include "brave/components/brave_wayback_machine/pref_names.h"
#endif
using BraveProfilePrefsBrowserTest = InProcessBrowserTest;
using BraveLocalStatePrefsBrowserTest = InProcessBrowserTest;
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
using BraveProfilePrefsBrowserTest = PlatformBrowserTest;
using BraveLocalStatePrefsBrowserTest = PlatformBrowserTest;
// Check download prompt preference is set to true by default.
IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, DownloadPromptDefault) {
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(prefs::kPromptForDownload));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kPromptForDownload));
}
IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest, MiscBravePrefs) {
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kHTTPSEVerywhereControlType));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kNoScriptControlType));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kNoScriptControlType));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kShieldsAdvancedViewEnabled));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(kShieldsStatsBadgeVisible));
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(kAdControlType));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(kGoogleLoginControlType));
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kShieldsStatsBadgeVisible));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kAdControlType));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kGoogleLoginControlType));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
brave_shields::prefs::kFBEmbedControlType));
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
brave_shields::prefs::kTwitterEmbedControlType));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
brave_shields::prefs::kLinkedInEmbedControlType));
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(kWebTorrentEnabled));
#if BUILDFLAG(ENABLE_BRAVE_WAYBACK_MACHINE)
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kWebTorrentEnabled));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kBraveWaybackMachineEnabled));
#endif
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(kHangoutsEnabled));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kHangoutsEnabled));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
brave_rewards::prefs::kHideButton));
#if BUILDFLAG(IPFS_ENABLED)
EXPECT_EQ(browser()->profile()->GetPrefs()->GetInteger(kIPFSResolveMethod),
EXPECT_EQ(chrome_test_utils::GetProfile(this)->GetPrefs()->GetInteger(
kIPFSResolveMethod),
static_cast<int>((ipfs::IPFSResolveMethodTypes::IPFS_ASK)));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetFilePath(kIPFSBinaryPath).empty());
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kIPFSAutoRedirectGateway));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)
->GetPrefs()
->GetFilePath(kIPFSBinaryPath)
.empty());
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kIPFSAutoRedirectGateway));
#endif
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kIPFSCompanionEnabled));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kIPFSCompanionEnabled));
#if BUILDFLAG(ETHEREUM_REMOTE_CLIENT_ENABLED)
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kERCLoadCryptoWalletsOnStartup));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kERCOptedIntoCryptoWallets));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kERCOptedIntoCryptoWallets));
#endif
#if BUILDFLAG(BRAVE_WALLET_ENABLED)
EXPECT_EQ(
browser()->profile()->GetPrefs()->GetInteger(kBraveWalletWeb3Provider),
static_cast<int>(brave_wallet::IsNativeWalletEnabled()
? brave_wallet::Web3ProviderTypes::BRAVE_WALLET
: brave_wallet::Web3ProviderTypes::ASK));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(kShowWalletIconOnToolbar));
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kBraveWalletBackupComplete));
EXPECT_EQ(chrome_test_utils::GetProfile(this)->GetPrefs()->GetInteger(
kBraveWalletWeb3Provider),
static_cast<int>(brave_wallet::IsNativeWalletEnabled()
? brave_wallet::Web3ProviderTypes::BRAVE_WALLET
: brave_wallet::Web3ProviderTypes::ASK));
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kShowWalletIconOnToolbar));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kBraveWalletBackupComplete));
#endif
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kMRUCyclingEnabled));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kMRUCyclingEnabled));
#if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
EXPECT_FALSE(
browser()->profile()->GetPrefs()->GetBoolean(kBraveGCMChannelStatus));
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
kBraveGCMChannelStatus));
#endif
}
IN_PROC_BROWSER_TEST_F(BraveProfilePrefsBrowserTest,
DisableGoogleServicesByDefault) {
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
embedder_support::kAlternateErrorPagesEnabled));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
spellcheck::prefs::kSpellCheckUseSpellingService));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kSafeBrowsingExtendedReportingOptInAllowed));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kSearchSuggestEnabled));
EXPECT_EQ(browser()->profile()->GetPrefs()->GetInteger(
EXPECT_EQ(chrome_test_utils::GetProfile(this)->GetPrefs()->GetInteger(
prefs::kNetworkPredictionOptions),
chrome_browser_net::NETWORK_PREDICTION_NEVER);
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kSigninAllowedOnNextStartup));
// Verify cloud print is disabled.
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kCloudPrintProxyEnabled));
EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
EXPECT_FALSE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kCloudPrintSubmitEnabled));
EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
#if !defined(OS_ANDROID)
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kNtpUseMostVisitedTiles));
EXPECT_TRUE(
browser()->profile()->GetPrefs()->GetBoolean(prefs::kHideWebStoreIcon));
#endif
EXPECT_TRUE(chrome_test_utils::GetProfile(this)->GetPrefs()->GetBoolean(
prefs::kHideWebStoreIcon));
}
#if !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(BraveLocalStatePrefsBrowserTest, DefaultLocalStateTest) {
EXPECT_TRUE(g_browser_process->local_state()->GetBoolean(
kDefaultBrowserPromptEnabled));
}
#endif
+8 -3
View File
@@ -5,14 +5,19 @@
#include "brave/grit/brave_theme_resources.h"
#include "brave/grit/brave_unscaled_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "ui/base/resource/resource_bundle.h"
using BraveResourcesBrowserTest = InProcessBrowserTest;
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
using BraveResourcesBrowserTest = PlatformBrowserTest;
// Check brave's theme resources pacakges are properly added.
IN_PROC_BROWSER_TEST_F(BraveResourcesBrowserTest, ResourceExistanceTest) {
IN_PROC_BROWSER_TEST_F(PlatformBrowserTest, ResourceExistanceTest) {
gfx::Image test_image =
ui::ResourceBundle::GetSharedInstance().GetImageNamed(
IDR_PRODUCT_LOGO_32_DEV);
@@ -6,9 +6,7 @@
#include "brave/components/brave_shields/browser/brave_shields_util.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/pref_names.h"
@@ -16,14 +14,21 @@
#include "content/public/test/browser_test.h"
#include "url/gurl.h"
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#endif
using brave_shields::ControlType;
class CookiePrefServiceTest : public InProcessBrowserTest {
class CookiePrefServiceTest : public PlatformBrowserTest {
public:
CookiePrefServiceTest() = default;
~CookiePrefServiceTest() override = default;
Profile* profile() { return browser()->profile(); }
Profile* profile() { return chrome_test_utils::GetProfile(this); }
HostContentSettingsMap* content_settings() {
return HostContentSettingsMapFactory::GetForProfile(profile());
@@ -17,15 +17,21 @@
#include "brave/components/brave_referrals/common/pref_names.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_test.h"
#include "net/base/url_util.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#endif
namespace {
// Request handler for stats and referral updates. The response this returns
@@ -51,7 +57,7 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequestForStats(
} // anonymous namespace
class BraveStatsUpdaterBrowserTest : public InProcessBrowserTest {
class BraveStatsUpdaterBrowserTest : public PlatformBrowserTest {
public:
void SetUp() override {
auto referral_initialized_callback = base::BindRepeating(
@@ -71,7 +77,7 @@ class BraveStatsUpdaterBrowserTest : public InProcessBrowserTest {
base::Unretained(this));
brave_stats::BraveStatsUpdater::SetStatsThresholdCallbackForTesting(
&stats_threshold_callback);
InProcessBrowserTest::SetUp();
PlatformBrowserTest::SetUp();
}
void TearDown() override {
@@ -80,7 +86,7 @@ class BraveStatsUpdaterBrowserTest : public InProcessBrowserTest {
brave_stats::BraveStatsUpdater::SetStatsUpdatedCallbackForTesting(nullptr);
brave_stats::BraveStatsUpdater::SetStatsThresholdCallbackForTesting(
nullptr);
InProcessBrowserTest::TearDown();
PlatformBrowserTest::TearDown();
}
void SetUpCommandLine(base::CommandLine* command_line) override {
@@ -8,7 +8,6 @@
#include "brave/browser/net/brave_system_request_handler.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/simple_url_loader_test_helper.h"
@@ -19,8 +18,14 @@
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
// Test to check if key is added for brave apis
class SystemNetworkContextManagerBrowsertest : public InProcessBrowserTest {
class SystemNetworkContextManagerBrowsertest : public PlatformBrowserTest {
public:
SystemNetworkContextManagerBrowsertest()
: https_server_(net::test_server::EmbeddedTestServer::TYPE_HTTPS) {
@@ -9,6 +9,7 @@
#include "brave/browser/brave_ads/ads_service_factory.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/components/ipfs/buildflags/buildflags.h"
#include "brave/components/tor/buildflags/buildflags.h"
#include "brave/components/tor/tor_constants.h"
#include "brave/components/tor/tor_utils.h"
#include "chrome/browser/browser_process.h"
@@ -16,11 +17,8 @@
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/prefs/pref_service.h"
#include "content/public/test/browser_test.h"
@@ -30,6 +28,14 @@
#include "brave/components/ipfs/features.h"
#endif
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#endif
namespace {
// An observer that returns back to test code after a new profile is
@@ -66,7 +72,7 @@ std::vector<TestProfileData> GetTestProfileData(
} // namespace
class BraveProfileManagerTest : public InProcessBrowserTest {
class BraveProfileManagerTest : public PlatformBrowserTest {
public:
BraveProfileManagerTest() {
#if BUILDFLAG(IPFS_ENABLED)
@@ -144,36 +150,43 @@ IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest,
Profile* profile = ProfileManager::GetActiveUserProfile();
Profile* otr_profile = profile->GetPrimaryOTRProfile();
#if !defined(OS_ANDROID)
profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
ui_test_utils::WaitForBrowserToOpen();
Profile* guest_profile =
profile_manager->GetProfileByPath(ProfileManager::GetGuestProfilePath());
ASSERT_TRUE(otr_profile->IsOffTheRecord());
ASSERT_TRUE(guest_profile->IsGuestSession());
EXPECT_EQ(brave_rewards::RewardsServiceFactory::GetForProfile(guest_profile),
nullptr);
EXPECT_EQ(brave_ads::AdsServiceFactory::GetForProfile(guest_profile),
nullptr);
#endif
ASSERT_TRUE(otr_profile->IsOffTheRecord());
EXPECT_NE(
brave_rewards::RewardsServiceFactory::GetForProfile(profile), nullptr);
EXPECT_EQ(
brave_rewards::RewardsServiceFactory::GetForProfile(otr_profile),
nullptr);
EXPECT_EQ(
brave_rewards::RewardsServiceFactory::GetForProfile(guest_profile),
nullptr);
EXPECT_NE(brave_ads::AdsServiceFactory::GetForProfile(profile), nullptr);
EXPECT_EQ(brave_ads::AdsServiceFactory::GetForProfile(otr_profile),
nullptr);
EXPECT_EQ(brave_ads::AdsServiceFactory::GetForProfile(guest_profile),
nullptr);
#if BUILDFLAG(IPFS_ENABLED)
EXPECT_NE(ipfs::IpfsServiceFactory::GetForContext(profile), nullptr);
EXPECT_EQ(ipfs::IpfsServiceFactory::GetForContext(otr_profile), nullptr);
#if !defined(OS_ANDROID)
EXPECT_EQ(ipfs::IpfsServiceFactory::GetForContext(guest_profile), nullptr);
#endif
#endif
}
#if BUILDFLAG(ENABLE_TOR)
IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest,
GetLastUsedProfileName) {
g_browser_process->local_state()->SetString(
@@ -190,3 +203,4 @@ IN_PROC_BROWSER_TEST_F(BraveProfileManagerTest,
profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir());
EXPECT_EQ(last_used_path.BaseName().AsUTF8Unsafe(), chrome::kInitialProfile);
}
#endif
+1 -1
View File
@@ -158,7 +158,7 @@ Config.prototype.isComponentBuild = function () {
}
Config.prototype.isDebug = function () {
return this.buildConfig === 'Debug'
return this.buildConfig === 'Debug' || this.buildConfig === 'brave_browser_tests'
}
Config.prototype.enableCDMHostVerification = function () {
+16 -4
View File
@@ -1,5 +1,6 @@
const path = require('path')
const build = require('../lib/build')
const config = require('../lib/config')
const util = require('../lib/util')
const assert = require('assert')
@@ -21,7 +22,11 @@ const getTestsToRun = (config, suite) => {
}
const test = (passthroughArgs, suite, buildConfig = config.defaultBuildConfig, options) => {
config.buildConfig = buildConfig
if (config.targetOS !== 'android')
config.buildConfig = buildConfig
else
config.buildConfig = 'Debug'
config.update(options)
let braveArgs = [
@@ -63,11 +68,18 @@ const test = (passthroughArgs, suite, buildConfig = config.defaultBuildConfig, o
braveArgs = braveArgs.concat(passthroughArgs)
let buildTarget = suite
if (suite === 'brave_unit_tests' || suite === 'brave_browser_tests')
buildTarget = "brave/test:" + suite
config.buildTarget = buildTarget
// Build the tests
if (suite === 'brave_unit_tests' || suite === 'brave_browser_tests') {
util.run('ninja', ['-C', config.outputDir, "brave/test:" + suite], config.defaultOptions)
if (config.targetOS === 'android' && suite === 'brave_browser_tests') {
// Only android browser tests use this standard build function, to minimize impact on other tests
build(buildConfig, options)
} else {
util.run('ninja', ['-C', config.outputDir, suite], config.defaultOptions)
util.run('ninja', ['-C', config.outputDir, buildTarget], config.defaultOptions)
}
if (config.targetOS === 'ios') {
+1
View File
@@ -234,6 +234,7 @@ program
.option('--target_arch <target_arch>', 'target architecture')
.option('--run_disabled_tests', 'run disabled tests')
.option('--manual_android_test_device', 'indicates that Android test device is run manually')
.option('--use_goma', 'whether to use Goma for building')
.arguments('[build_config]')
.action(test.bind(null, parsedArgs.unknown))
@@ -6,29 +6,35 @@
#include "brave/components/brave_shields/common/brave_shield_constants.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "content/public/test/browser_test.h"
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
const GURL& GetBraveURL() {
static const GURL kBraveURL("https://www.brave.com");
return kBraveURL;
}
class BraveContentSettingsRegistryBrowserTest : public InProcessBrowserTest {
class BraveContentSettingsRegistryBrowserTest : public PlatformBrowserTest {
public:
using InProcessBrowserTest::InProcessBrowserTest;
using PlatformBrowserTest::PlatformBrowserTest;
HostContentSettingsMap* content_settings() {
return HostContentSettingsMapFactory::GetForProfile(browser()->profile());
return HostContentSettingsMapFactory::GetForProfile(
chrome_test_utils::GetProfile(this));
}
HostContentSettingsMap* private_content_settings() {
return HostContentSettingsMapFactory::GetForProfile(
browser()->profile()->GetPrimaryOTRProfile());
chrome_test_utils::GetProfile(this)->GetPrimaryOTRProfile());
}
private:
+7 -2
View File
@@ -5,11 +5,16 @@
#include "base/environment.h"
#include "chrome/common/channel_info.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/version_info/channel.h"
#include "content/public/test/browser_test.h"
using BraveChannelInfoBrowserTest = InProcessBrowserTest;
#if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h"
#else
#include "chrome/test/base/in_process_browser_test.h"
#endif
using BraveChannelInfoBrowserTest = PlatformBrowserTest;
IN_PROC_BROWSER_TEST_F(BraveChannelInfoBrowserTest, DefaultChannelTest) {
#if defined(OFFICIAL_BUILD)
+105 -1
View File
@@ -912,7 +912,111 @@ if (!is_android) {
public_deps = [ ":browser_tests_runner" ]
}
} else { # if (!is_android) {
group("brave_browser_tests") {
test("brave_browser_tests") {
configs += [ "//build/config:precompiled_headers" ]
defines = [
"HAS_OUT_OF_PROC_TEST_RUNNER",
"CHROME_VERSION_MAJOR=" + chrome_version_major,
]
use_default_launcher = false
android_manifest =
"${target_gen_dir}/brave_browser_tests_manifest/AndroidManifest.xml"
android_manifest_dep = ":brave_browser_tests_manifest"
deps = [
"//brave/app/theme:brave_theme_resources_grit",
"//brave/app/theme:brave_unscaled_resources_grit",
"//brave/browser/brave_ads",
"//brave/browser/ethereum_remote_client/buildflags",
"//brave/browser/net",
"//brave/browser/themes",
"//brave/common:pref_names",
"//brave/common:switches",
"//brave/components/brave_referrals/browser",
"//brave/components/brave_referrals/common",
"//brave/components/brave_rewards/common",
"//brave/components/brave_shields/browser",
"//brave/components/brave_shields/common",
"//brave/components/brave_sync:prefs",
"//brave/components/brave_wallet/browser",
"//brave/components/brave_wayback_machine",
"//brave/components/ipfs",
"//brave/components/ipfs/buildflags",
"//brave/components/l10n/browser",
"//brave/components/tor",
"//brave/components/tor:utils",
"//brave/components/tor/buildflags",
"//chrome:chrome_android_core",
"//chrome/android:app_hooks_java",
"//chrome/browser:browser_process",
"//chrome/browser/flags:flags_android",
"//chrome/browser/metrics:test_support",
"//chrome/test:android_browsertests_assets",
"//chrome/test:android_browsertests_java",
"//chrome/test:browser_tests_runner",
"//chrome/test:test_support",
"//chrome/test:test_support_ui_android",
"//components/bookmarks/browser",
"//components/browser_ui/widget/android:java",
"//components/content_settings/core/browser",
"//components/content_settings/renderer",
"//components/embedder_support",
"//components/externalauth/android:google_delegate_public_impl_java",
"//components/federated_learning",
"//components/language/core/common",
"//components/network_time",
"//components/spellcheck/browser",
"//services/device/public/cpp:device_features",
# TODO(crbug.com/961849): This is needed for ShellManager which is what
# the ChromeBrowserTestsActivity is using to build the java UI. It's
# likely we want to replace it with something new that uses ChromeWindow
# and CompositorViewHolder instead.
"//content/shell:content_shell_lib",
"//content/test:android_test_message_pump_support",
"//testing/android/native_test:native_test_support",
]
# There are three types of tests that need to be rewritten for Android:
# 1. using extensions
# 2. using desktop specific UI elements (e.g. TabStripModelObserver)
# 3. using ui_test_utils.h
sources = [
"//brave/app/brave_main_delegate_browsertest.cc",
"//brave/app/brave_main_delegate_runtime_flags_browsertest.cc",
"//brave/browser/brave_prefs_browsertest.cc",
"//brave/browser/brave_resources_browsertest.cc",
"//brave/browser/brave_shields/cookie_pref_service_browsertest.cc",
"//brave/browser/brave_stats/brave_stats_updater_browsertest.cc",
"//brave/browser/net/brave_system_request_handler_browsertest.cc",
"//brave/browser/profiles/brave_profile_manager_browsertest.cc",
"//brave/chromium_src/components/content_settings/core/browser/brave_content_settings_registry_browsertest.cc",
"//brave/common/brave_channel_info_browsertest.cc",
"//brave/components/content_settings/renderer/brave_content_settings_agent_impl_autoplay_browsertest.cc",
"//brave/components/l10n/browser/locale_helper_mock.cc",
"//brave/components/l10n/browser/locale_helper_mock.h",
"//chrome/test/android/browsertests_apk/android_browsertests_jni_onload.cc",
"//chrome/test/base/android/android_browser_test_browsertest_android.cc",
]
data = [
"$root_out_dir/brave_100_percent.pak",
"$root_out_dir/brave_resources.pak",
"$root_gen_dir/chrome/android/chrome_apk_paks/chrome_100_percent.pak",
"$root_gen_dir/chrome/android/chrome_apk_paks/locales/en-US.pak",
"$root_gen_dir/chrome/android/chrome_apk_paks/resources.pak",
"$root_gen_dir/components/components_resources.pak",
"$root_gen_dir/components/dev_ui_components_resources.pak",
"$root_out_dir/browser_tests.pak",
"//brave/components/brave_perf_predictor/resources/entities-httparchive-nostats.json",
]
}
jinja_template("brave_browser_tests_manifest") {
testonly = true
input = "//brave/android/browsertests_apk/AndroidManifest.xml.jinja2"
output =
"${target_gen_dir}/brave_browser_tests_manifest/AndroidManifest.xml"
}
}