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

Unified Diff: ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm

Issue 2915603002: Do not use CRWWebController in FormSuggestionControllerTest. (Closed)
Patch Set: Fixed compilation 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
« no previous file with comments | « ios/chrome/browser/autofill/form_input_accessory_view_controller.mm ('k') | ios/chrome/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm
diff --git a/ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm b/ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm
index 2bbd34cebb1a77af2fe33f3aefd2a59ef0dea6ae..0f9e99e9aa688af14eb192f94e7310d691ddad40 100644
--- a/ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm
+++ b/ios/chrome/browser/autofill/form_suggestion_controller_unittest.mm
@@ -9,15 +9,17 @@
#include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h"
+#include "base/path_service.h"
+#include "base/strings/stringprintf.h"
#import "components/autofill/ios/browser/form_suggestion.h"
#import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h"
#import "ios/chrome/browser/autofill/form_suggestion_provider.h"
#import "ios/chrome/browser/autofill/form_suggestion_view.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/web/chrome_web_test.h"
-#include "ios/chrome/test/base/scoped_block_swizzler.h"
+#import "ios/web/public/navigation_manager.h"
#import "ios/web/public/web_state/ui/crw_web_view_proxy.h"
-#import "ios/web/web_state/ui/crw_web_controller.h"
+#import "ios/web/public/web_state/web_state.h"
#import "testing/gtest_mac.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#include "third_party/ocmock/gtest_support.h"
@@ -161,16 +163,6 @@ class FormSuggestionControllerTest : public ChromeWebTest {
LoadHtml(@"<html></html>", GURL(url));
}
- // Swizzles the current web controller to set whether the content is HTML.
- void SetContentIsHtml(BOOL content_is_html) {
- id content_is_html_block = ^BOOL(CRWWebController* webController) {
- return content_is_html;
- };
- content_is_html_swizzler_.reset(new ScopedBlockSwizzler(
- [CRWWebController class], @selector(contentIsHTML),
- content_is_html_block));
- }
-
protected:
// Sets up |suggestion_controller_| with the specified array of
// FormSuggestionProviders.
@@ -227,9 +219,6 @@ class FormSuggestionControllerTest : public ChromeWebTest {
}
}
- // Swizzler for [CRWWebController contentIsHTML].
- std::unique_ptr<ScopedBlockSwizzler> content_is_html_swizzler_;
-
// The FormSuggestionController under test.
FormSuggestionController* suggestion_controller_;
@@ -261,10 +250,22 @@ TEST_F(FormSuggestionControllerTest, PageLoadShouldBeIgnoredWhenNotWebScheme) {
// Tests that pages whose content isn't HTML aren't processed.
TEST_F(FormSuggestionControllerTest, PageLoadShouldBeIgnoredWhenNotHtml) {
SetUpController(@[]);
- SetCurrentUrl("http://foo.com");
- SetContentIsHtml(NO);
- [suggestion_controller_ webState:web_state() didLoadPageWithSuccess:YES];
+ // Construct file:// URL for a PDF file.
+ base::FilePath path;
+ base::PathService::Get(base::DIR_MODULE, &path);
+ const char kPdfFilePath[] = "ios/testing/data/http_server_files/testpage.pdf";
+ path = path.Append(FILE_PATH_LITERAL(kPdfFilePath));
+ GURL url(base::StringPrintf("file://%s", path.value().c_str()));
+
+ // Load PDF file URL.
+ web::NavigationManager::WebLoadParams params(url);
+ web_state()->GetNavigationManager()->LoadURLWithParams(params);
+ WaitForCondition(^{
+ return !web_state()->IsLoading();
+ });
+
+ ASSERT_EQ("application/pdf", web_state()->GetContentsMimeType());
EXPECT_FALSE(GetSuggestionView(input_accessory_view_));
EXPECT_OCMOCK_VERIFY(mock_js_suggestion_manager_);
}
« no previous file with comments | « ios/chrome/browser/autofill/form_input_accessory_view_controller.mm ('k') | ios/chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698