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

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: Addressed code review comments Created 4 years, 5 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"
8 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
9 #include "blimp/client/core/blimp_navigation_controller_delegate.h" 8 #include "blimp/client/core/blimp_navigation_controller_delegate.h"
9 #include "blimp/client/feature/mock_navigation_feature.h"
10 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
13 using testing::_;
14
12 namespace blimp { 15 namespace blimp {
13 namespace client { 16 namespace client {
14 namespace { 17 namespace {
15 18
16 const GURL kExampleURL = GURL("https://www.example.com/"); 19 const GURL kExampleURL = GURL("https://www.example.com/");
17 20
18 class TestBlimpNavigationControllerDelegate 21 class TestBlimpNavigationControllerDelegate
19 : public BlimpNavigationControllerDelegate { 22 : public BlimpNavigationControllerDelegate {
20 public: 23 public:
21 TestBlimpNavigationControllerDelegate() = default; 24 TestBlimpNavigationControllerDelegate() = default;
22 ~TestBlimpNavigationControllerDelegate() override = default; 25 ~TestBlimpNavigationControllerDelegate() override = default;
23 26
24 void NotifyURLLoaded(const GURL& url) override { last_loaded_url_ = url; } 27 MOCK_METHOD0(OnNavigationStateChanged, void());
25 28
26 GURL GetLastLoadedURL() { return last_loaded_url_; } 29 GURL GetLastLoadedURL() { return last_loaded_url_; }
27 30
28 private: 31 private:
29 GURL last_loaded_url_; 32 GURL last_loaded_url_;
30 33
31 DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate); 34 DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate);
32 }; 35 };
33 36
34 TEST(BlimpNavigationControllerImplTest, Basic) { 37 TEST(BlimpNavigationControllerImplTest, Basic) {
35 base::MessageLoop loop; 38 base::MessageLoop loop;
36 39
37 TestBlimpNavigationControllerDelegate delegate; 40 TestBlimpNavigationControllerDelegate delegate;
38 BlimpNavigationControllerImpl navigation_controller(&delegate); 41 BlimpNavigationControllerImpl navigation_controller(&delegate);
39 42
43 MockNavigationFeature feature;
44 feature.SetDelegate(1, &navigation_controller);
45 navigation_controller.SetNavigationFeatureForTesting(&feature);
46
47 EXPECT_CALL(delegate, OnNavigationStateChanged()).Times(1);
48
40 navigation_controller.LoadURL(kExampleURL); 49 navigation_controller.LoadURL(kExampleURL);
41 EXPECT_EQ(kExampleURL, navigation_controller.GetURL()); 50 EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
42 51
52 EXPECT_CALL(feature, GoBack(_)).Times(1);
53 EXPECT_CALL(feature, GoForward(_)).Times(1);
54 EXPECT_CALL(feature, Reload(_)).Times(1);
55
56 navigation_controller.GoBack();
57 navigation_controller.GoForward();
58 navigation_controller.Reload();
59
43 loop.RunUntilIdle(); 60 loop.RunUntilIdle();
44 EXPECT_EQ(kExampleURL, delegate.GetLastLoadedURL());
45 } 61 }
46 62
47 } // namespace 63 } // namespace
48 } // namespace client 64 } // namespace client
49 } // namespace blimp 65 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698