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

Unified Diff: ios/web/web_state/web_state_impl_unittest.mm

Issue 1851003003: [ios] Added web// public API to let embedder observe loading progress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation Created 4 years, 8 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/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/web_state_impl_unittest.mm
diff --git a/ios/web/web_state/web_state_impl_unittest.mm b/ios/web/web_state/web_state_impl_unittest.mm
index 2502cb917dc0755e569e35837e4a8f5d5429891e..a47a626c817b5c74d9195c9ec61f3e214df3bd10 100644
--- a/ios/web/web_state/web_state_impl_unittest.mm
+++ b/ios/web/web_state/web_state_impl_unittest.mm
@@ -14,6 +14,7 @@
#include "ios/web/public/load_committed_details.h"
#include "ios/web/public/test/test_browser_state.h"
#include "ios/web/public/web_state/global_web_state_observer.h"
+#include "ios/web/public/web_state/web_state_delegate.h"
#include "ios/web/public/web_state/web_state_observer.h"
#include "ios/web/public/web_state/web_state_policy_decider.h"
#import "ios/web/test/web_test.h"
@@ -106,6 +107,27 @@ class TestGlobalWebStateObserver : public GlobalWebStateObserver {
bool web_state_destroyed_called_;
};
+// Test delegate to check that the WebStateDelegate methods are called as
+// expected.
+class TestWebStateDelegate : public WebStateDelegate {
+ public:
+ TestWebStateDelegate() : load_progress_changed_called_(false) {}
+
+ // Methods returning true if the corresponding WebStateObserver method has
+ // been called.
+ bool load_progress_changed_called() const {
+ return load_progress_changed_called_;
+ }
+
+ private:
+ // WebStateObserver implementation:
+ void LoadProgressChanged(WebState* source, double progress) override {
+ load_progress_changed_called_ = true;
+ }
+
+ bool load_progress_changed_called_;
+};
+
// Test observer to check that the WebStateObserver methods are called as
// expected.
class TestWebStateObserver : public WebStateObserver {
@@ -344,6 +366,17 @@ TEST_F(WebStateTest, ObserverTest) {
EXPECT_EQ(nullptr, observer->web_state());
}
+// Tests that WebStateDelegate methods appropriately called.
+TEST_F(WebStateTest, DelegateTest) {
+ TestWebStateDelegate delegate;
+ web_state_->SetDelegate(&delegate);
+
+ // Test that LoadProgressChanged() is called.
+ EXPECT_FALSE(delegate.load_progress_changed_called());
+ web_state_->SendChangeLoadProgress(0.0);
+ EXPECT_TRUE(delegate.load_progress_changed_called());
+}
+
// Verifies that GlobalWebStateObservers are called when expected.
TEST_F(WebStateTest, GlobalObserverTest) {
std::unique_ptr<TestGlobalWebStateObserver> observer(
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698