Commit 6119a279 authored by lpromero's avatar lpromero Committed by Commit bot

Unit test FindInPageMediator.

BUG=none
R=rohitrao@chromium.org

Review-Url: https://codereview.chromium.org/2812133004
Cr-Commit-Position: refs/heads/master@{#464389}
parent 4901e4ce
...@@ -48,3 +48,20 @@ source_set("find_in_page_ui") { ...@@ -48,3 +48,20 @@ source_set("find_in_page_ui") {
libs = [ "UIKit.framework" ] libs = [ "UIKit.framework" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
} }
source_set("unit_tests") {
sources = [
"find_in_page_mediator_unittest.mm",
]
deps = [
":find_in_page",
":find_in_page_ui",
"//base",
"//ios/chrome/browser/web_state_list",
"//ios/chrome/browser/web_state_list:test_support",
"//testing/gtest",
"//third_party/ocmock",
]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
}
...@@ -60,6 +60,10 @@ ...@@ -60,6 +60,10 @@
return self; return self;
} }
- (void)dealloc {
_webStateList->RemoveObserver(_webStateListObserver.get());
}
- (void)stopFinding { - (void)stopFinding {
web::WebState* webState = self.webStateList->GetActiveWebState(); web::WebState* webState = self.webStateList->GetActiveWebState();
FindTabHelper* helper = FindTabHelper::FromWebState(webState); FindTabHelper* helper = FindTabHelper::FromWebState(webState);
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/clean/chrome/browser/ui/find_in_page/find_in_page_mediator.h"
#include "base/memory/ptr_util.h"
#include "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h"
#include "ios/chrome/browser/web_state_list/web_state_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace {
class FindInPageMediatorTest : public PlatformTest {
public:
FindInPageMediatorTest() {
web_state_list_ = base::MakeUnique<WebStateList>(&web_state_list_delegate_);
provider_ = [OCMockObject
niceMockForProtocol:@protocol(FindInPageConsumerProvider)];
}
protected:
std::unique_ptr<WebStateList> web_state_list_;
FakeWebStateListDelegate web_state_list_delegate_;
id provider_;
};
} // namespace
TEST_F(FindInPageMediatorTest, Init) {
FindInPageMediator* mediator =
[[FindInPageMediator alloc] initWithWebStateList:web_state_list_.get()
provider:provider_
dispatcher:nil];
[mediator self];
}
...@@ -21,6 +21,7 @@ test("ios_clean_chrome_unittests") { ...@@ -21,6 +21,7 @@ test("ios_clean_chrome_unittests") {
# Add unit_tests target here. # Add unit_tests target here.
"//ios/clean/chrome/browser/ui/bookmarks:unit_tests", "//ios/clean/chrome/browser/ui/bookmarks:unit_tests",
"//ios/clean/chrome/browser/ui/context_menu:unit_tests", "//ios/clean/chrome/browser/ui/context_menu:unit_tests",
"//ios/clean/chrome/browser/ui/find_in_page:unit_tests",
"//ios/clean/chrome/browser/ui/ntp:unit_tests", "//ios/clean/chrome/browser/ui/ntp:unit_tests",
"//ios/clean/chrome/browser/ui/omnibox:unit_tests", "//ios/clean/chrome/browser/ui/omnibox:unit_tests",
"//ios/clean/chrome/browser/ui/recent_tabs:unit_tests", "//ios/clean/chrome/browser/ui/recent_tabs:unit_tests",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment