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

Side by Side Diff: ios/chrome/browser/web/sad_tab_tab_helper_unittest.mm

Issue 2807843002: Refactor creation of SadTabView into a tab helper object (Closed)
Patch Set: Attempt to fix build dependency Created 3 years, 8 months 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
OLDNEW
(Empty)
1 // Copyright 2017 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 #import "ios/chrome/browser/web/sad_tab_tab_helper.h"
6
7 #import "ios/chrome/browser/web/sad_tab_tab_helper_delegate.h"
8 #import "ios/web/public/test/fakes/test_web_state.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h"
11
12 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support."
14 #endif
15
16 // A configurable TabHelper delegate for testing.
17 @interface TabHelperTestDelegate : NSObject<SadTabTabHelperDelegate>
18 @property(readwrite, assign) BOOL active;
19 @end
20
21 @implementation TabHelperTestDelegate
22 @synthesize active = _active;
23 - (BOOL)isTabVisibleForTabHelper:(SadTabTabHelper*)tabHelper {
24 return self.active;
25 }
26 @end
27
28 class SadTabTabHelperTest : public PlatformTest {
29 protected:
30 SadTabTabHelperTest() : delegate_([[TabHelperTestDelegate alloc] init]) {
31 SadTabTabHelper::CreateForWebState(&web_state_, delegate_);
32 }
33 TabHelperTestDelegate* delegate_;
34 web::TestWebState web_state_;
35 };
36
37 // Tests that the presentation-block can be suppressed by the delegate.
38 TEST_F(SadTabTabHelperTest, PresentationCanBeSuppressedByDelegate) {
39 // WebState should not have presented a transient content view.
40 EXPECT_FALSE(web_state_.IsShowingTransientContentView());
41
42 // Helper should get notified of render process failure,
43 // but the delegate should suppress the presentation of a content view.
44 web_state_.OnRenderProcessGone();
45 EXPECT_FALSE(web_state_.IsShowingTransientContentView());
46 }
47
48 // Tests that the presentation-block can be allowed by the delegate.
49 TEST_F(SadTabTabHelperTest, PresentationCanBeAllowedByDelegate) {
50 delegate_.active = YES;
51
52 // WebState should not have presented a transient content view.
53 EXPECT_FALSE(web_state_.IsShowingTransientContentView());
54
55 // Helper should get notified of render process failure.
56 // The delegate should allow the presentation of a content view.
57 web_state_.OnRenderProcessGone();
58 EXPECT_TRUE(web_state_.IsShowingTransientContentView());
59 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/sad_tab_tab_helper_delegate.h ('k') | ios/web/public/test/fakes/test_web_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698