Commit 09f7288c authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Deflake InstalledAppProviderTest.TestOneRelatedAppNotInstalled

The InstalledAppProviderTest suite uses AsyncTask, which apparently
requires a BrowserTaskEnvironment for the AsyncTask to actually run
(sometimes it runs anyways - I don't know why).

Bug: 1041909
Change-Id: Ida7a8ee8296ce489b560cec00e3b0ca2c4d7d982
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2003751
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732227}
parent 6757b7d9
...@@ -86,6 +86,7 @@ class PackageHash { ...@@ -86,6 +86,7 @@ class PackageHash {
@VisibleForTesting @VisibleForTesting
public static void setGlobalSaltForTesting(byte[] salt) { public static void setGlobalSaltForTesting(byte[] salt) {
if (sInstance == null) getInstance();
sInstance.mProfileSalt = salt.clone(); sInstance.mProfileSalt = salt.clone();
sInstance.mIncognitoSalt = salt.clone(); sInstance.mIncognitoSalt = salt.clone();
} }
...@@ -115,7 +116,7 @@ class PackageHash { ...@@ -115,7 +116,7 @@ class PackageHash {
} }
byte[] digest = hasher.doFinal(packageNameBytes); byte[] digest = hasher.doFinal(packageNameBytes);
// Take just the first two bytes of the digest. // Take just the first two bytes of the digest.
int hash = ((((int) digest[0]) & 0xff) << 8) | (((int) digest[1]) & 0xff); int hash = (((digest[0]) & 0xff) << 8) | ((digest[1]) & 0xff);
return (short) hash; return (short) hash;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "chrome/android/native_j_unittests_jni_headers/InstalledAppProviderTest_jni.h" #include "chrome/android/native_j_unittests_jni_headers/InstalledAppProviderTest_jni.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
...@@ -11,7 +12,8 @@ using base::android::AttachCurrentThread; ...@@ -11,7 +12,8 @@ using base::android::AttachCurrentThread;
class InstalledAppProviderTest : public ::testing::Test { class InstalledAppProviderTest : public ::testing::Test {
public: public:
InstalledAppProviderTest() InstalledAppProviderTest()
: j_test_( : task_environment_(content::BrowserTaskEnvironment::MainThreadType::UI),
j_test_(
Java_InstalledAppProviderTest_Constructor(AttachCurrentThread())) {} Java_InstalledAppProviderTest_Constructor(AttachCurrentThread())) {}
void SetUp() override { void SetUp() override {
...@@ -23,11 +25,8 @@ class InstalledAppProviderTest : public ::testing::Test { ...@@ -23,11 +25,8 @@ class InstalledAppProviderTest : public ::testing::Test {
} }
private: private:
content::BrowserTaskEnvironment task_environment_;
base::android::ScopedJavaGlobalRef<jobject> j_test_; base::android::ScopedJavaGlobalRef<jobject> j_test_;
}; };
// TODO(crbug/1041909): Disable failing test. This looks like magic but the test
// target is defined by the macro below. This is a hack until these tests are
// easier to disable.
#define TestOneRelatedAppNotInstalled DISABLED_TestOneRelatedAppNotInstalled
JAVA_TESTS(InstalledAppProviderTest, j_test()) JAVA_TESTS(InstalledAppProviderTest, j_test())
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