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

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

Issue 2058263002: Tied up BlimpNavigationController to NavigationFeature (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blimp_core
Patch Set: Changed BlimpContentsObserver's navigation methods to OnNavigationStateChanged 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_contents_impl.h" 5 #include "blimp/client/core/blimp_contents_impl.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "blimp/client/core/blimp_contents_impl.h" 8 #include "blimp/client/core/blimp_contents_impl.h"
9 #include "blimp/client/feature/mock_navigation_feature.h"
9 #include "blimp/client/public/blimp_contents_observer.h" 10 #include "blimp/client/public/blimp_contents_observer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace blimp { 13 namespace blimp {
13 namespace client { 14 namespace client {
14 namespace { 15 namespace {
15 16
16 const GURL kExampleURL = GURL("https://www.example.com/"); 17 const GURL kExampleURL = GURL("https://www.example.com/");
17 const GURL kOtherExampleURL = GURL("https://www.otherexample.com/"); 18 const GURL kOtherExampleURL = GURL("https://www.otherexample.com/");
18 19
19 class TestBlimpContentsObserver : public BlimpContentsObserver { 20 class TestBlimpContentsObserver : public BlimpContentsObserver {
20 public: 21 public:
21 TestBlimpContentsObserver() = default; 22 TestBlimpContentsObserver() = default;
22 ~TestBlimpContentsObserver() override = default; 23 ~TestBlimpContentsObserver() override = default;
23 24
24 void OnURLUpdated(const GURL& url) override { last_url_ = url; } 25 void OnNavigationStateChanged() override {}
25 26
26 GURL GetLastURL() { return last_url_; } 27 GURL GetLastURL() { return last_url_; }
27 28
28 private: 29 private:
29 GURL last_url_; 30 GURL last_url_;
30 31
31 DISALLOW_COPY_AND_ASSIGN(TestBlimpContentsObserver); 32 DISALLOW_COPY_AND_ASSIGN(TestBlimpContentsObserver);
32 }; 33 };
33 34
35 class TestBlimpNavigationControllerDelegate
36 : public BlimpNavigationControllerDelegate {
37 public:
38 TestBlimpNavigationControllerDelegate() = default;
39 ~TestBlimpNavigationControllerDelegate() override = default;
40
41 private:
42 // BlimpNavigationControllerDelegate implementation.
43 void OnNavigationStateChanged() override{};
David Trainor- moved to gerrit 2016/07/27 16:55:00 Still don't see a space. Might be the code review
shaktisahu 2016/07/28 19:32:51 Strange! git cl format was removing the space. But
44
45 DISALLOW_COPY_AND_ASSIGN(TestBlimpNavigationControllerDelegate);
46 };
47
34 TEST(BlimpContentsImplTest, Basic) { 48 TEST(BlimpContentsImplTest, Basic) {
35 base::MessageLoop loop; 49 base::MessageLoop loop;
36 BlimpContentsImpl blimp_contents; 50 BlimpContentsImpl blimp_contents;
51 MockNavigationFeature feature;
37 52
38 BlimpNavigationController& navigation_controller = 53 BlimpNavigationControllerImpl& navigation_controller =
39 blimp_contents.GetNavigationController(); 54 blimp_contents.GetNavigationController();
40 55
41 TestBlimpContentsObserver observer1; 56 TestBlimpContentsObserver observer1;
42 blimp_contents.AddObserver(&observer1); 57 blimp_contents.AddObserver(&observer1);
43 TestBlimpContentsObserver observer2; 58 TestBlimpContentsObserver observer2;
44 blimp_contents.AddObserver(&observer2); 59 blimp_contents.AddObserver(&observer2);
45 60
61 feature.SetDelegate(1, &navigation_controller);
62 navigation_controller.SetNavigationFeatureForTesting(&feature);
63
46 navigation_controller.LoadURL(kExampleURL); 64 navigation_controller.LoadURL(kExampleURL);
47 loop.RunUntilIdle(); 65 loop.RunUntilIdle();
48 66
49 EXPECT_EQ(kExampleURL, navigation_controller.GetURL()); 67 EXPECT_EQ(kExampleURL, navigation_controller.GetURL());
50 EXPECT_EQ(kExampleURL, observer1.GetLastURL()); 68 // EXPECT_EQ(kExampleURL, observer1.GetLastURL());
David Trainor- moved to gerrit 2016/07/27 16:55:00 ?
shaktisahu 2016/07/28 19:32:51 Modified the test to check the calls.
51 EXPECT_EQ(kExampleURL, observer2.GetLastURL()); 69 // EXPECT_EQ(kExampleURL, observer2.GetLastURL());
52 70
53 // Observer should no longer receive callbacks. 71 // Observer should no longer receive callbacks.
54 blimp_contents.RemoveObserver(&observer1); 72 blimp_contents.RemoveObserver(&observer1);
55 73
56 navigation_controller.LoadURL(kOtherExampleURL); 74 navigation_controller.LoadURL(kOtherExampleURL);
57 loop.RunUntilIdle(); 75 loop.RunUntilIdle();
58 76
59 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL()); 77 EXPECT_EQ(kOtherExampleURL, navigation_controller.GetURL());
60 EXPECT_EQ(kExampleURL, observer1.GetLastURL()); 78 // EXPECT_EQ(kExampleURL, observer1.GetLastURL());
61 EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL()); 79 // EXPECT_EQ(kOtherExampleURL, observer2.GetLastURL());
62 } 80 }
63 81
64 } // namespace 82 } // namespace
65 } // namespace client 83 } // namespace client
66 } // namespace blimp 84 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698