Commit 391aeeec authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Get unit tests passing with multiwindow enabled.

In order for the unit test suites to run with the iOS 13 Scene APIs:

- Create a test-specific scene delegate (similar to the test-specific
  app delegate). For now, this is a no-op delegate.

- Update the plist for unittests using the scene APIs to use this as
  the scene delegate.

- Early return from one test that uses a code path that expects
  SceneState objects to be created.

Bug: 1084483
Change-Id: Ibd0efbc72b55818647076481b361b3252e847520
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2241652Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783002}
parent 3293e946
...@@ -50,6 +50,16 @@ static char** g_argv; ...@@ -50,6 +50,16 @@ static char** g_argv;
@end @end
#endif // TARGET_IPHONE_SIMULATOR #endif // TARGET_IPHONE_SIMULATOR
// No-op scene delegate for unit tests. Note that this is created along with
// the application delegate, so they need to be separate objects (the same
// object can't be both the app and scene delegate, since new scene delegates
// are created for each scene).
@interface ChromeUnitTestSceneDelegate : NSObject <UISceneDelegate>
@end
@implementation ChromeUnitTestSceneDelegate
@end
@interface ChromeUnitTestDelegate : NSObject <GoogleTestRunnerDelegate> { @interface ChromeUnitTestDelegate : NSObject <GoogleTestRunnerDelegate> {
base::scoped_nsobject<UIWindow> _window; base::scoped_nsobject<UIWindow> _window;
} }
......
...@@ -53,6 +53,7 @@ source_set("unit_tests") { ...@@ -53,6 +53,7 @@ source_set("unit_tests") {
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/tabs", "//ios/chrome/browser/tabs",
"//ios/chrome/browser/ui/main:scene", "//ios/chrome/browser/ui/main:scene",
"//ios/chrome/browser/ui/util:multiwindow_util",
"//ios/chrome/common/app_group", "//ios/chrome/common/app_group",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//ios/public/provider/chrome/browser:browser", "//ios/public/provider/chrome/browser:browser",
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "base/mac/foundation_util.h" #import "base/mac/foundation_util.h"
#import "ios/chrome/app/chrome_overlay_window_testing.h" #import "ios/chrome/app/chrome_overlay_window_testing.h"
#import "ios/chrome/browser/ui/util/multi_window_support.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/OCMock/OCMock.h"
...@@ -22,6 +23,11 @@ using MainApplicationDelegateTest = PlatformTest; ...@@ -22,6 +23,11 @@ using MainApplicationDelegateTest = PlatformTest;
// is called when the application is launched in background. // is called when the application is launched in background.
// http://crbug.com/437307 // http://crbug.com/437307
TEST_F(MainApplicationDelegateTest, CrashIfNotInitialized) { TEST_F(MainApplicationDelegateTest, CrashIfNotInitialized) {
// Skip for scene API for now.
// TODO(crbug.com/1093755) : Support this test in with the scene API.
if (IsSceneStartupSupported())
return;
// Save both ChromeBrowserProvider as MainController register new instance. // Save both ChromeBrowserProvider as MainController register new instance.
ios::ChromeBrowserProvider* stashed_chrome_browser_provider = ios::ChromeBrowserProvider* stashed_chrome_browser_provider =
ios::GetChromeBrowserProvider(); ios::GetChromeBrowserProvider();
......
...@@ -173,26 +173,26 @@ ...@@ -173,26 +173,26 @@
</array> </array>
<key>SSOAuthURLScheme</key> <key>SSOAuthURLScheme</key>
<string>${IOS_BUNDLE_ID_PREFIX}.sso.${PRODUCT_NAME:rfc1034identifier}</string> <string>${IOS_BUNDLE_ID_PREFIX}.sso.${PRODUCT_NAME:rfc1034identifier}</string>
<key>UIApplicationSceneManifest</key> <key>UIApplicationSceneManifest</key>
<dict> <dict>
<key>UIApplicationSupportsMultipleScenes</key> <key>UIApplicationSupportsMultipleScenes</key>
<false/> <false/>
<key>UISceneConfigurations</key> <key>UISceneConfigurations</key>
<dict> <dict>
<key>UIWindowSceneSessionRoleApplication</key> <key>UIWindowSceneSessionRoleApplication</key>
<array> <array>
<dict> <dict>
<key>UISceneClassName</key> <key>UISceneClassName</key>
<string>UIWindowScene</string> <string>UIWindowScene</string>
<key>UISceneDelegateClassName</key> <key>UISceneDelegateClassName</key>
<string>SceneDelegate</string> <string>ChromeUnitTestSceneDelegate</string>
<key>UISceneConfigurationName</key> <key>UISceneConfigurationName</key>
<string>Default Configuration</string> <string>Default Configuration</string>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
</dict> </dict>
</array> </array>
</dict> </dict>
</dict> </dict>
</dict> </dict>
</plist> </plist>
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