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

Unified Diff: ios/web/web_state/ui/crw_web_controller_observer_unittest.mm

Issue 2567303003: [ios] Removed unused CRWWebControllerObserver methods. (Closed)
Patch Set: Self review Created 4 years 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/web_state/ui/crw_web_controller_observer_unittest.mm
diff --git a/ios/web/web_state/ui/crw_web_controller_observer_unittest.mm b/ios/web/web_state/ui/crw_web_controller_observer_unittest.mm
index c36bd94edd6e9580a0f74848176dbb87a06f118a..0ba13539d8f8b3e66a3d696c54a8a0ef8851dead 100644
--- a/ios/web/web_state/ui/crw_web_controller_observer_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_observer_unittest.mm
@@ -2,18 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "ios/web/web_state/ui/crw_web_controller.h"
+#import "ios/web/public/web_state/crw_web_controller_observer.h"
-#include "base/json/json_writer.h"
#include "base/mac/scoped_nsobject.h"
-#include "base/values.h"
-#import "ios/testing/ocmock_complex_type_helper.h"
-#import "ios/web/public/web_state/crw_web_controller_observer.h"
-#import "ios/web/public/web_state/js/crw_js_injection_manager.h"
-#import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
#import "ios/web/test/crw_fake_web_controller_observer.h"
#import "ios/web/test/web_test_with_web_controller.h"
-#include "testing/gtest_mac.h"
namespace web {
@@ -23,7 +16,7 @@ class CRWWebControllerObserverTest : public web::WebTestWithWebController {
void SetUp() override {
web::WebTestWithWebController::SetUp();
fake_web_controller_observer_.reset(
- [[CRWFakeWebControllerObserver alloc] initWithCommandPrefix:@"test"]);
+ [[CRWFakeWebControllerObserver alloc] init]);
[web_controller() addObserver:fake_web_controller_observer_];
}
@@ -43,44 +36,4 @@ TEST_F(CRWWebControllerObserverTest, PageLoaded) {
EXPECT_TRUE([fake_web_controller_observer_ pageLoaded]);
}
-// Tests that web controller receives a JS message from the page.
-TEST_F(CRWWebControllerObserverTest, HandleCommand) {
- LoadHtml(@"<p></p>");
- ASSERT_EQ(0U, [fake_web_controller_observer_ commandsReceived].size());
- base::DictionaryValue command;
- command.SetString("command", "test.testMessage");
- std::string message;
- base::JSONWriter::Write(command, &message);
- ExecuteJavaScript([NSString
- stringWithFormat:@"__gCrWeb.message.invokeOnHost(%s)", message.c_str()]);
- WaitForBackgroundTasks();
- ASSERT_EQ(1U, [fake_web_controller_observer_ commandsReceived].size());
- EXPECT_TRUE(
- [fake_web_controller_observer_ commandsReceived][0]->Equals(&command));
-}
-
-// Send a large number of commands and check each one is immediately received.
-TEST_F(CRWWebControllerObserverTest, HandleMultipleCommands) {
- LoadHtml(@"<p></p>");
-
- base::DictionaryValue command;
- command.SetString("command", "test.testMessage");
- int kNumberMessages = 200;
- for (int count = 0; count <= kNumberMessages; count++) {
- std::string message;
- command.SetInteger("number", count);
- base::JSONWriter::Write(command, &message);
- ASSERT_EQ(0U, [fake_web_controller_observer_ commandsReceived].size());
- ExecuteJavaScript(
- [NSString stringWithFormat:@"__gCrWeb.message.invokeOnHost(%s)",
- message.c_str()]);
- WaitForBackgroundTasks();
- ASSERT_EQ(1U, [fake_web_controller_observer_ commandsReceived].size());
- EXPECT_TRUE(
- [fake_web_controller_observer_ commandsReceived][0]->Equals(&command));
- [fake_web_controller_observer_ commandsReceived].clear();
- ASSERT_EQ(0U, [fake_web_controller_observer_ commandsReceived].size());
- }
-}
-
} // namespace web
« no previous file with comments | « ios/web/test/crw_fake_web_controller_observer_unittest.mm ('k') | ios/web/web_state/ui/crw_web_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698