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

Side by Side Diff: blimp/client/core/blimp_navigation_controller_impl_unittest.cc

Issue 2058263002: Tied up BlimpNavigationController to NavigationFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_core
Patch Set: Hooked up the Java layer Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/client/core/blimp_navigation_controller_impl.h" 5 #include "blimp/client/core/blimp_navigation_controller_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "blimp/client/core/blimp_navigation_controller_delegate.h" 10 #include "blimp/client/core/blimp_navigation_controller_delegate.h"
11 #include "blimp/client/feature/mock_navigation_feature.h"
12 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
11 14
15 using testing::_;
16
12 namespace blimp { 17 namespace blimp {
13 namespace client { 18 namespace client {
14 namespace { 19 namespace {
15 20
16 const GURL kExampleURL = GURL("https://www.example.com/"); 21 const GURL kExampleURL = GURL("https://www.example.com/");
17 22
18 class TestBlimpNavigationControllerDelegate 23 class TestBlimpNavigationControllerDelegate
19 : public BlimpNavigationControllerDelegate { 24 : public BlimpNavigationControllerDelegate {
20 public: 25 public:
21 TestBlimpNavigationControllerDelegate() = default; 26 TestBlimpNavigationControllerDelegate() = default;
22 ~TestBlimpNavigationControllerDelegate() override = default; 27 ~TestBlimpNavigationControllerDelegate() override = default;
23 28
24 void NotifyURLLoaded(const GURL& url) override { last_loaded_url_ = url; } 29 void OnUrlChanged(const GURL& url) override { last_loaded_url_ = url; }
30 void OnFaviconChanged(const SkBitmap& favicon) override {}
31 void OnTitleChanged(const std::string& title) override {}
32 void OnLoadingChanged(bool loading) override {}
33 void OnPageLoadStatusUpdate(bool completed) override {}
25 34
26 GURL GetLastLoadedURL() { return last_loaded_url_; } 35 GURL GetLastLoadedURL() { return last_loaded_url_; }
27 36
28 private: 37 private:
29 GURL last_loaded_url_; 38 GURL last_loaded_url_;
30 39
31 DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate); 40 DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate);
32 }; 41 };
33 42
34 TEST(BlimpNavigationControllerImplTest, Basic) { 43 TEST(BlimpNavigationControllerImplTest, Basic) {
David Trainor- moved to gerrit 2016/06/29 17:27:15 Should we add a separate test for these extra call
35 base::MessageLoop loop; 44 base::MessageLoop loop;
36 45
37 TestBlimpNavigationControllerDelegate delegate; 46 TestBlimpNavigationControllerDelegate delegate;
38 BlimpNavigationControllerImpl navigation_controller(&delegate); 47 BlimpNavigationControllerImpl navigation_controller(&delegate);
39 48
49 MockNavigationFeature feature;
50 feature.SetDelegate(1, &navigation_controller);
51 navigation_controller.SetNavigationFeatureForTesting(&feature);
52
53 EXPECT_CALL(feature, GoBack(_)).Times(1);
54 EXPECT_CALL(feature, GoForward(_)).Times(1);
55 EXPECT_CALL(feature, Reload(_)).Times(1);
56
40 navigation_controller.LoadURL(kExampleURL); 57 navigation_controller.LoadURL(kExampleURL);
41 EXPECT_EQ(kExampleURL, navigation_controller.GetURL()); 58 EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
42 59
60 navigation_controller.GoBack();
61 navigation_controller.GoForward();
62 navigation_controller.Reload();
63
43 loop.RunUntilIdle(); 64 loop.RunUntilIdle();
44 EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL()); 65 EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL());
45 } 66 }
46 67
47 } // namespace 68 } // namespace
48 } // namespace client 69 } // namespace client
49 } // namespace blimp 70 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698