Commit bcd86748 authored by Ian Struiksma's avatar Ian Struiksma Committed by Commit Bot

Add method to get Profile from PlatformBrowserTest

For many Autofill and Password Manager tests, the path to getting them
running on Android will require access to Profile from a source other
than browser()-profile().

Adding a method here that follows how content::WebContents is accessed.

Bug: 1127019
Change-Id: I160d6bbc5d0d9437d9a8baef0075ed7566db4425
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536552Reviewed-by: default avatardanakj <danakj@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Ian Struiksma <ianstruiksma@google.com>
Cr-Commit-Position: refs/heads/master@{#828911}
parent 89b93b80
...@@ -29,4 +29,17 @@ content::WebContents* GetActiveWebContents(PlatformBrowserTest* browser_test) { ...@@ -29,4 +29,17 @@ content::WebContents* GetActiveWebContents(PlatformBrowserTest* browser_test) {
#endif #endif
} }
Profile* GetProfile(PlatformBrowserTest* browser_test) {
#if defined(OS_ANDROID)
for (size_t i = 0; i < TabModelList::size(); ++i) {
if (TabModelList::get(i)->IsActiveModel())
return TabModelList::get(i)->GetProfile();
}
NOTREACHED() << "No active TabModel??";
return nullptr;
#else
return browser_test->browser()->profile();
#endif
}
} // namespace chrome_test_utils } // namespace chrome_test_utils
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace content { namespace content {
class WebContents; class WebContents;
} }
class Profile;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/test/base/android/android_browser_test.h" #include "chrome/test/base/android/android_browser_test.h"
...@@ -27,6 +28,10 @@ namespace chrome_test_utils { ...@@ -27,6 +28,10 @@ namespace chrome_test_utils {
// window created by tests, more specific behaviour requires other means. // window created by tests, more specific behaviour requires other means.
content::WebContents* GetActiveWebContents(PlatformBrowserTest* browser_test); content::WebContents* GetActiveWebContents(PlatformBrowserTest* browser_test);
// Returns the active Profile. On desktop this is in the first browser
// window created by tests, more specific behaviour requires other means.
Profile* GetProfile(PlatformBrowserTest* browser_test);
} // namespace chrome_test_utils } // namespace chrome_test_utils
#endif // CHROME_TEST_BASE_CHROME_TEST_UTILS_H_ #endif // CHROME_TEST_BASE_CHROME_TEST_UTILS_H_
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