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

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

Issue 2902403002: Add KVO compliant title property to CWVWebView. (Closed)
Patch Set: Respond to comments. 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..8cebb94e72b8125e8ba8abcc688f59d52748bb2e 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,11 @@
#import <Foundation/Foundation.h>
#import "base/mac/scoped_nsobject.h"
-#import "ios/web_view/test/boolean_observer.h"
+#include "base/strings/stringprintf.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"
#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 +96,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 = base::StringPrintf(
+ "<a id='link_1' href='%s'>Link 1</a>", page_2_url.spec().c_str());
+ GURL page_1_url = GetUrlForPageWithTitleAndBody(
+ base::SysNSStringToUTF8(page_1_title), page_1_html);
+
+ LoadUrl(web_view_, net::NSURLWithGURL(page_1_url));
+ EXPECT_NSEQ(page_1_title, observer.lastValue);
+
+ // Navigate to page 2.
+ EXPECT_TRUE(test::TapChromeWebViewElementWithId(web_view_, @"link_1"));
+ WaitForPageLoadCompletion(web_view_);
+ EXPECT_NSEQ(page_2_title, observer.lastValue);
+
+ // Navigate back to page 1.
+ [web_view_ goBack];
+ WaitForPageLoadCompletion(web_view_);
+ EXPECT_NSEQ(page_1_title, observer.lastValue);
+}
+
} // namespace ios_web_view

Powered by Google App Engine
This is Rietveld 408576698