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

Unified Diff: ios/web_view/test/chrome_web_view_kvo_inttest.mm

Issue 2902403002: Add KVO compliant title property to CWVWebView. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/test/chrome_web_view_kvo_inttest.mm
diff --git a/ios/web_view/test/chrome_web_view_kvo_inttest.mm b/ios/web_view/test/chrome_web_view_kvo_inttest.mm
index 4425439ebad39f05ea02b05e8a6aebc112f732cf..319abfc098279abc4176903e793b6077e45187d3 100644
--- a/ios/web_view/test/chrome_web_view_kvo_inttest.mm
+++ b/ios/web_view/test/chrome_web_view_kvo_inttest.mm
@@ -6,8 +6,10 @@
#import <Foundation/Foundation.h>
#import "base/mac/scoped_nsobject.h"
-#import "ios/web_view/test/boolean_observer.h"
+#import "base/strings/sys_string_conversions.h"
#import "ios/web_view/test/chrome_web_view_test.h"
+#import "ios/web_view/test/observers/boolean_observer.h"
+#import "ios/web_view/test/observers/string_observer.h"
Eugene But (OOO till 7-30) 2017/05/25 17:43:03 Do we actually need 2 different observers for BOOL
michaeldo 2017/05/26 14:59:01 It's true that they are not required as the one th
Eugene But (OOO till 7-30) 2017/05/31 22:10:00 Objective-C has one KVO callback for all types, be
Eugene But (OOO till 7-30) 2017/06/01 15:53:54 Please look at this comment
#import "ios/web_view/test/web_view_interaction_test_util.h"
#import "net/base/mac/url_conversions.h"
#include "testing/gtest_mac.h"
@@ -93,4 +95,33 @@ TEST_F(ChromeWebViewKvoTest, CanGoBackForward) {
EXPECT_TRUE([forward_observer.lastValue boolValue]);
}
+// Tests that CWVWebView correctly reports current |title|.
+TEST_F(ChromeWebViewKvoTest, Title) {
+ StringObserver* observer = [[StringObserver alloc] init];
+ [observer setObservedObject:web_view_ keyPath:@"title"];
+
+ NSString* page_2_title = @"Page 2";
+ GURL page_2_url =
+ GetUrlForPageWithTitle(base::SysNSStringToUTF8(page_2_title));
+
+ NSString* page_1_title = @"Page 1";
+ std::string page_1_html =
+ "<a id='link_1' href='" + page_2_url.spec() + "'>Link 1</a>";
Eugene But (OOO till 7-30) 2017/05/25 17:43:03 Please se StringPrint instead of +
michaeldo 2017/05/26 14:59:01 Done.
+ GURL page_1_url = GetUrlForPageWithTitleAndBody(
+ base::SysNSStringToUTF8(page_1_title), page_1_html);
+
+ LoadUrl(web_view_, net::NSURLWithGURL(page_1_url));
+ EXPECT_NSEQ(observer.lastValue, page_1_title);
+
+ // Navigate to page 2.
+ EXPECT_TRUE(test::TapChromeWebViewElementWithId(web_view_, @"link_1"));
+ WaitForPageLoadCompletion(web_view_);
+ EXPECT_NSEQ(observer.lastValue, page_2_title);
Eugene But (OOO till 7-30) 2017/05/25 17:43:03 EXPECT_NSEQ takes first argument as expected value
michaeldo 2017/05/26 14:59:01 Done.
+
+ // Navigate back to page 1.
+ [web_view_ goBack];
+ WaitForPageLoadCompletion(web_view_);
+ EXPECT_NSEQ(observer.lastValue, page_1_title);
+}
+
} // namespace ios_web_view

Powered by Google App Engine
This is Rietveld 408576698