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

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

Issue 2325893002: [blimp] Add support for having multiple tabs (Closed)
Patch Set: Add tablet and non-blimp support Created 4 years, 3 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 "base/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h" 7 #include "blimp/client/core/contents/blimp_navigation_controller_delegate.h"
8 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h" 8 #include "blimp/client/core/contents/blimp_navigation_controller_impl.h"
9 #include "blimp/client/core/contents/fake_navigation_feature.h" 9 #include "blimp/client/core/contents/fake_navigation_feature.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using testing::_; 13 using testing::_;
14 14
15 namespace blimp { 15 namespace blimp {
16 namespace client { 16 namespace client {
17 namespace { 17 namespace {
18 18
19 const int kDummyBlimpContentsId = 0;
19 const GURL kExampleURL = GURL("https://www.example.com/"); 20 const GURL kExampleURL = GURL("https://www.example.com/");
20 21
21 class MockBlimpNavigationControllerDelegate 22 class MockBlimpNavigationControllerDelegate
22 : public BlimpNavigationControllerDelegate { 23 : public BlimpNavigationControllerDelegate {
23 public: 24 public:
24 MockBlimpNavigationControllerDelegate() = default; 25 MockBlimpNavigationControllerDelegate() = default;
25 ~MockBlimpNavigationControllerDelegate() override = default; 26 ~MockBlimpNavigationControllerDelegate() override = default;
26 27
27 MOCK_METHOD0(OnNavigationStateChanged, void()); 28 MOCK_METHOD0(OnNavigationStateChanged, void());
28 MOCK_METHOD1(OnLoadingStateChanged, void(bool loading)); 29 MOCK_METHOD1(OnLoadingStateChanged, void(bool loading));
29 30
30 private: 31 private:
31 DISALLOW_COPY_AND_ASSIGN(MockBlimpNavigationControllerDelegate); 32 DISALLOW_COPY_AND_ASSIGN(MockBlimpNavigationControllerDelegate);
32 }; 33 };
33 34
34 TEST(BlimpNavigationControllerImplTest, BackForwardNavigation) { 35 TEST(BlimpNavigationControllerImplTest, BackForwardNavigation) {
35 base::MessageLoop loop; 36 base::MessageLoop loop;
36 37
37 testing::StrictMock<MockBlimpNavigationControllerDelegate> delegate; 38 testing::StrictMock<MockBlimpNavigationControllerDelegate> delegate;
38 testing::StrictMock<FakeNavigationFeature> feature; 39 testing::StrictMock<FakeNavigationFeature> feature;
39 BlimpNavigationControllerImpl navigation_controller(&delegate, &feature); 40 BlimpNavigationControllerImpl navigation_controller(kDummyBlimpContentsId,
41 &delegate, &feature);
40 feature.SetDelegate(1, &navigation_controller); 42 feature.SetDelegate(1, &navigation_controller);
41 43
42 EXPECT_CALL(delegate, OnNavigationStateChanged()); 44 EXPECT_CALL(delegate, OnNavigationStateChanged());
43 45
44 navigation_controller.LoadURL(kExampleURL); 46 navigation_controller.LoadURL(kExampleURL);
45 base::RunLoop().RunUntilIdle(); 47 base::RunLoop().RunUntilIdle();
46 EXPECT_EQ(kExampleURL, navigation_controller.GetURL()); 48 EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
47 49
48 EXPECT_CALL(feature, GoBack(_)); 50 EXPECT_CALL(feature, GoBack(_));
49 EXPECT_CALL(feature, GoForward(_)); 51 EXPECT_CALL(feature, GoForward(_));
50 EXPECT_CALL(feature, Reload(_)); 52 EXPECT_CALL(feature, Reload(_));
51 53
52 navigation_controller.GoBack(); 54 navigation_controller.GoBack();
53 navigation_controller.GoForward(); 55 navigation_controller.GoForward();
54 navigation_controller.Reload(); 56 navigation_controller.Reload();
55 57
56 base::RunLoop().RunUntilIdle(); 58 base::RunLoop().RunUntilIdle();
57 } 59 }
58 60
59 TEST(BlimpNavigationControllerImplTest, Loading) { 61 TEST(BlimpNavigationControllerImplTest, Loading) {
60 testing::InSequence s; 62 testing::InSequence s;
61 base::MessageLoop loop; 63 base::MessageLoop loop;
62 64
63 testing::StrictMock<MockBlimpNavigationControllerDelegate> delegate; 65 testing::StrictMock<MockBlimpNavigationControllerDelegate> delegate;
64 testing::StrictMock<FakeNavigationFeature> feature; 66 testing::StrictMock<FakeNavigationFeature> feature;
65 BlimpNavigationControllerImpl navigation_controller(&delegate, &feature); 67 BlimpNavigationControllerImpl navigation_controller(kDummyBlimpContentsId,
68 &delegate, &feature);
66 feature.SetDelegate(1, &navigation_controller); 69 feature.SetDelegate(1, &navigation_controller);
67 70
68 EXPECT_CALL(delegate, OnNavigationStateChanged()); 71 EXPECT_CALL(delegate, OnNavigationStateChanged());
69 EXPECT_CALL(delegate, OnLoadingStateChanged(true)); 72 EXPECT_CALL(delegate, OnLoadingStateChanged(true));
70 EXPECT_CALL(delegate, OnNavigationStateChanged()); 73 EXPECT_CALL(delegate, OnNavigationStateChanged());
71 EXPECT_CALL(delegate, OnLoadingStateChanged(false)); 74 EXPECT_CALL(delegate, OnLoadingStateChanged(false));
72 75
73 NavigationFeature::NavigationFeatureDelegate* feature_delegate = 76 NavigationFeature::NavigationFeatureDelegate* feature_delegate =
74 static_cast<NavigationFeature::NavigationFeatureDelegate*>( 77 static_cast<NavigationFeature::NavigationFeatureDelegate*>(
75 &navigation_controller); 78 &navigation_controller);
76 79
77 feature_delegate->OnLoadingChanged(1, true); 80 feature_delegate->OnLoadingChanged(1, true);
78 feature_delegate->OnLoadingChanged(1, false); 81 feature_delegate->OnLoadingChanged(1, false);
79 } 82 }
80 83
81 } // namespace 84 } // namespace
82 } // namespace client 85 } // namespace client
83 } // namespace blimp 86 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_navigation_controller_impl.cc ('k') | blimp/client/core/contents/navigation_feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698