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

Unified Diff: ios/chrome/browser/find_in_page/find_in_page_js_unittest.mm

Issue 2711513002: [ios] Simplifies the Find In Page JS unittest. (Closed)
Patch Set: Rebased. Created 3 years, 10 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/chrome/browser/find_in_page/find_in_page_js_unittest.mm
diff --git a/ios/chrome/browser/web/find_in_page_js_unittest.mm b/ios/chrome/browser/find_in_page/find_in_page_js_unittest.mm
similarity index 89%
rename from ios/chrome/browser/web/find_in_page_js_unittest.mm
rename to ios/chrome/browser/find_in_page/find_in_page_js_unittest.mm
index 89ee82120b92075a7a536edd60b51cbea64a3c40..38cd2670db90a41ffeee3981e02f3e716ecefa1c 100644
--- a/ios/chrome/browser/web/find_in_page_js_unittest.mm
+++ b/ios/chrome/browser/find_in_page/find_in_page_js_unittest.mm
@@ -4,16 +4,19 @@
#import <UIKit/UIKit.h>
+#include "base/mac/foundation_util.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
-#import "ios/chrome/browser/find_in_page/find_in_page_controller.h"
+#import "ios/chrome/browser/find_in_page/find_in_page_model.h"
+#import "ios/chrome/browser/find_in_page/js_findinpage_manager.h"
#import "ios/chrome/browser/web/chrome_web_test.h"
+#import "ios/web/public/web_state/crw_web_view_proxy.h"
+#import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
#import "ios/web/public/web_state/web_state.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gtest_mac.h"
-#import "third_party/ocmock/OCMock/OCMock.h"
-// Unit tests for the models/resources/find_in_page.js JavaScript file.
+// Unit tests for the find_in_page.js JavaScript file.
namespace {
@@ -63,7 +66,11 @@ class FindInPageJsTest : public ChromeWebTest {
// Loads the given HTML, then loads the |findInPage| JavaScript.
void LoadHtml(NSString* html) {
ChromeWebTest::LoadHtml(html);
- [findInPageController_ initFindInPage];
+
+ // Inject and initialize the find in page javascript.
+ [findInPageJsManager_ inject];
+ CGRect frame = [web_state()->GetWebViewProxy() bounds];
+ [findInPageJsManager_ setWidth:frame.size.width height:frame.size.height];
}
// Runs the given JavaScript and asserts that the result matches the given
@@ -94,15 +101,15 @@ class FindInPageJsTest : public ChromeWebTest {
void SetUp() override {
ChromeWebTest::SetUp();
- mockDelegate_.reset([[OCMockObject
- niceMockForProtocol:@protocol(FindInPageControllerDelegate)] retain]);
- findInPageController_.reset([[FindInPageController alloc]
- initWithWebState:web_state()
- delegate:mockDelegate_]);
+ findInPageModel_.reset([[FindInPageModel alloc] init]);
+ findInPageJsManager_.reset([base::mac::ObjCCastStrict<JsFindinpageManager>(
+ [web_state()->GetJSInjectionReceiver()
+ instanceOfClass:[JsFindinpageManager class]]) retain]);
+ findInPageJsManager_.get().findInPageModel = findInPageModel_;
}
- base::scoped_nsobject<FindInPageController> findInPageController_;
- base::scoped_nsobject<id> mockDelegate_;
+ base::scoped_nsobject<FindInPageModel> findInPageModel_;
+ base::scoped_nsobject<JsFindinpageManager> findInPageJsManager_;
};
// Performs a search, then calls |incrementIndex| to loop through the
« no previous file with comments | « ios/chrome/browser/find_in_page/BUILD.gn ('k') | ios/chrome/browser/find_in_page/js_findinpage_manager_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698