Commit 381389a6 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

Fix unit_tests in notouch mode

Some tests have incorrect expectations given the features
enabled in this mode. The safe browsing tests were failing
due to using the v4 database which required pumping messages
on the IO thread to complete initialization.

Bug: 974405
Change-Id: I238ab3b9d4f87603c3c79a45ab2c2492dee27fa3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1674044
Commit-Queue: Ian Vollick <vollick@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672544}
parent f5652e55
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/feature_utilities.h"
#include "chrome/browser/download/download_prompt_status.h" #include "chrome/browser/download/download_prompt_status.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
...@@ -1570,6 +1571,11 @@ TEST_F(ChromeDownloadManagerDelegateTest, RequestConfirmation_Android) { ...@@ -1570,6 +1571,11 @@ TEST_F(ChromeDownloadManagerDelegateTest, RequestConfirmation_Android) {
TEST_F(ChromeDownloadManagerDelegateTest, TEST_F(ChromeDownloadManagerDelegateTest,
RequestConfirmation_Android_WithLocationChangeEnabled) { RequestConfirmation_Android_WithLocationChangeEnabled) {
#if defined(OS_ANDROID)
// We do not prompt for location in this case.
if (chrome::android::IsNoTouchModeEnabled())
return;
#endif
DeleteContents(); DeleteContents();
SetContents(CreateTestWebContents()); SetContents(CreateTestWebContents());
......
...@@ -123,14 +123,10 @@ class PlatformParentalControlsValue { ...@@ -123,14 +123,10 @@ class PlatformParentalControlsValue {
} // namespace } // namespace
#endif // OS_WIN #endif // OS_WIN
namespace { // static
static constexpr IncognitoModePrefs::Availability kDefaultAvailability = // Sadly, this is required until c++17.
#if defined(INCOGNITO_DEFAULT_DISABLED) constexpr IncognitoModePrefs::Availability
IncognitoModePrefs::DISABLED; IncognitoModePrefs::kDefaultAvailability;
#else
IncognitoModePrefs::ENABLED;
#endif
} // namespace
// static // static
bool IncognitoModePrefs::IntToAvailability(int in_value, bool IncognitoModePrefs::IntToAvailability(int in_value,
......
...@@ -39,6 +39,13 @@ class IncognitoModePrefs { ...@@ -39,6 +39,13 @@ class IncognitoModePrefs {
AVAILABILITY_NUM_TYPES AVAILABILITY_NUM_TYPES
}; };
static constexpr Availability kDefaultAvailability =
#if defined(INCOGNITO_DEFAULT_DISABLED)
DISABLED;
#else
ENABLED;
#endif
// Register incognito related preferences. // Register incognito related preferences.
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
......
...@@ -32,9 +32,9 @@ TEST_F(IncognitoModePrefsTest, IntToAvailability) { ...@@ -32,9 +32,9 @@ TEST_F(IncognitoModePrefsTest, IntToAvailability) {
EXPECT_EQ(IncognitoModePrefs::FORCED, incognito); EXPECT_EQ(IncognitoModePrefs::FORCED, incognito);
EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito)); EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(10, &incognito));
EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); EXPECT_EQ(IncognitoModePrefs::kDefaultAvailability, incognito);
EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito)); EXPECT_FALSE(IncognitoModePrefs::IntToAvailability(-1, &incognito));
EXPECT_EQ(IncognitoModePrefs::ENABLED, incognito); EXPECT_EQ(IncognitoModePrefs::kDefaultAvailability, incognito);
} }
TEST_F(IncognitoModePrefsTest, GetAvailability) { TEST_F(IncognitoModePrefsTest, GetAvailability) {
......
...@@ -900,7 +900,7 @@ TEST_F(ProfileManagerTest, GetLastUsedProfileAllowedByPolicy) { ...@@ -900,7 +900,7 @@ TEST_F(ProfileManagerTest, GetLastUsedProfileAllowedByPolicy) {
ASSERT_TRUE(profile); ASSERT_TRUE(profile);
EXPECT_FALSE(profile->IsOffTheRecord()); EXPECT_FALSE(profile->IsOffTheRecord());
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
EXPECT_EQ(IncognitoModePrefs::ENABLED, EXPECT_EQ(IncognitoModePrefs::kDefaultAvailability,
IncognitoModePrefs::GetAvailability(prefs)); IncognitoModePrefs::GetAvailability(prefs));
ASSERT_TRUE(profile->GetOffTheRecordProfile()); ASSERT_TRUE(profile->GetOffTheRecordProfile());
......
...@@ -303,6 +303,8 @@ class SafeBrowsingBlockingPageTestBase ...@@ -303,6 +303,8 @@ class SafeBrowsingBlockingPageTestBase
Profile* profile = Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext()); Profile::FromBrowserContext(web_contents()->GetBrowserContext());
safe_browsing_service->AddPrefService(profile->GetPrefs()); safe_browsing_service->AddPrefService(profile->GetPrefs());
content::BrowserThread::RunAllPendingTasksOnThreadForTesting(
content::BrowserThread::IO);
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
// EventRouterFactory redirects incognito context to original profile. // EventRouterFactory redirects incognito context to original profile.
test_event_router_ = test_event_router_ =
...@@ -1111,6 +1113,8 @@ class SafeBrowsingBlockingQuietPageTest ...@@ -1111,6 +1113,8 @@ class SafeBrowsingBlockingQuietPageTest
TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService( TestingBrowserProcess::GetGlobal()->SetSafeBrowsingService(
safe_browsing_service); safe_browsing_service);
g_browser_process->safe_browsing_service()->Initialize(); g_browser_process->safe_browsing_service()->Initialize();
content::BrowserThread::RunAllPendingTasksOnThreadForTesting(
content::BrowserThread::IO);
} }
void TearDown() override { void TearDown() override {
......
...@@ -99,6 +99,8 @@ class SafeBrowsingUIManagerTest : public ChromeRenderViewHostTestHarness { ...@@ -99,6 +99,8 @@ class SafeBrowsingUIManagerTest : public ChromeRenderViewHostTestHarness {
safe_browsing_service->AddPrefService( safe_browsing_service->AddPrefService(
Profile::FromBrowserContext(web_contents()->GetBrowserContext()) Profile::FromBrowserContext(web_contents()->GetBrowserContext())
->GetPrefs()); ->GetPrefs());
content::BrowserThread::RunAllPendingTasksOnThreadForTesting(
content::BrowserThread::IO);
} }
void TearDown() override { void TearDown() override {
......
...@@ -3226,6 +3226,10 @@ test("unit_tests") { ...@@ -3226,6 +3226,10 @@ test("unit_tests") {
configs += [ "//build/config:precompiled_headers" ] configs += [ "//build/config:precompiled_headers" ]
if (is_android && notouch_build) {
configs += [ "//chrome/browser:notouch_config" ]
}
data_deps = [ data_deps = [
"//chrome/test/data/media/engagement/preload:generate_preload_list", "//chrome/test/data/media/engagement/preload:generate_preload_list",
"//chrome/test/data/media/engagement/preload:test_data", "//chrome/test/data/media/engagement/preload:test_data",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment