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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ios/chrome/app/main_application_delegate.h"
6
7 #import <Foundation/Foundation.h>
8
9 #import "base/mac/foundation_util.h"
10 #include "base/mac/scoped_nsobject.h"
11 #import "ios/chrome/app/chrome_overlay_window_testing.h"
12 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
13 #include "testing/platform_test.h"
14 #import "third_party/ocmock/OCMock/OCMock.h"
15
16 // Tests that the application does not crash if |applicationDidEnterBackground|
17 // is called when the application is launched in background.
18 // http://crbug.com/437307
19 TEST(MainApplicationDelegateTest, CrashIfNotInitialized) {
20 // Save both ChromeBrowserProvider as MainController register new instance.
21 ios::ChromeBrowserProvider* stashed_chrome_browser_provider =
22 ios::GetChromeBrowserProvider();
23
24 id application = [OCMockObject niceMockForClass:[UIApplication class]];
25 UIApplicationState backgroundState = UIApplicationStateBackground;
26 [[[application stub] andReturnValue:OCMOCK_VALUE(backgroundState)]
27 applicationState];
28
29 MainApplicationDelegate* delegate =
30 [[[MainApplicationDelegate alloc] init] autorelease];
31 [delegate application:application didFinishLaunchingWithOptions:nil];
32 [delegate applicationDidEnterBackground:application];
33
34 // Clean up the size class recorder, which is created by the main window via
35 // a previous call to |application:didFinishLaunchingWithOptions:|, to prevent
36 // it from interfering with subsequent tests.
37 ChromeOverlayWindow* mainWindow =
38 base::mac::ObjCCastStrict<ChromeOverlayWindow>([delegate window]);
39 [mainWindow unsetSizeClassRecorder];
40
41 // Restore both ChromeBrowserProvider to its original value and destroy
42 // instances created by MainController.
43 DCHECK_NE(ios::GetChromeBrowserProvider(), stashed_chrome_browser_provider);
44 delete ios::GetChromeBrowserProvider();
45 ios::SetChromeBrowserProvider(stashed_chrome_browser_provider);
46 }
OLDNEW
« 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