Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: ios/chrome/app/main_application_delegate_unittest.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/app/main_application_delegate_testing.h ('k') | ios/chrome/app/main_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/app/main_application_delegate_unittest.mm
diff --git a/ios/chrome/app/main_application_delegate_unittest.mm b/ios/chrome/app/main_application_delegate_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ba947d29f2e9b04795991ff45db5977137fffa13
--- /dev/null
+++ b/ios/chrome/app/main_application_delegate_unittest.mm
@@ -0,0 +1,46 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/app/main_application_delegate.h"
+
+#import <Foundation/Foundation.h>
+
+#import "base/mac/foundation_util.h"
+#include "base/mac/scoped_nsobject.h"
+#import "ios/chrome/app/chrome_overlay_window_testing.h"
+#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
+#include "testing/platform_test.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
+
+// Tests that the application does not crash if |applicationDidEnterBackground|
+// is called when the application is launched in background.
+// http://crbug.com/437307
+TEST(MainApplicationDelegateTest, CrashIfNotInitialized) {
+ // Save both ChromeBrowserProvider as MainController register new instance.
+ ios::ChromeBrowserProvider* stashed_chrome_browser_provider =
+ ios::GetChromeBrowserProvider();
+
+ id application = [OCMockObject niceMockForClass:[UIApplication class]];
+ UIApplicationState backgroundState = UIApplicationStateBackground;
+ [[[application stub] andReturnValue:OCMOCK_VALUE(backgroundState)]
+ applicationState];
+
+ MainApplicationDelegate* delegate =
+ [[[MainApplicationDelegate alloc] init] autorelease];
+ [delegate application:application didFinishLaunchingWithOptions:nil];
+ [delegate applicationDidEnterBackground:application];
+
+ // Clean up the size class recorder, which is created by the main window via
+ // a previous call to |application:didFinishLaunchingWithOptions:|, to prevent
+ // it from interfering with subsequent tests.
+ ChromeOverlayWindow* mainWindow =
+ base::mac::ObjCCastStrict<ChromeOverlayWindow>([delegate window]);
+ [mainWindow unsetSizeClassRecorder];
+
+ // Restore both ChromeBrowserProvider to its original value and destroy
+ // instances created by MainController.
+ DCHECK_NE(ios::GetChromeBrowserProvider(), stashed_chrome_browser_provider);
+ delete ios::GetChromeBrowserProvider();
+ ios::SetChromeBrowserProvider(stashed_chrome_browser_provider);
+}
« no previous file with comments | « ios/chrome/app/main_application_delegate_testing.h ('k') | ios/chrome/app/main_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698