OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include <memory> | |
6 | |
7 #include "base/macros.h" | |
8 #include "base/run_loop.h" | |
9 #include "mojo/public/cpp/bindings/binding.h" | |
10 #include "services/navigation/public/interfaces/view.mojom.h" | |
11 #include "services/service_manager/public/cpp/service.h" | |
12 #include "services/service_manager/public/cpp/service_test.h" | |
13 | |
14 namespace navigation { | |
15 | |
16 class NavigationTest : public service_manager::test::ServiceTest, | |
17 public mojom::ViewClient { | |
18 public: | |
19 NavigationTest() | |
20 : service_manager::test::ServiceTest("navigation_unittests"), | |
21 binding_(this) {} | |
22 ~NavigationTest() override {} | |
23 | |
24 protected: | |
25 void SetUp() override { | |
26 service_manager::test::ServiceTest::SetUp(); | |
27 connector()->StartService("test_wm"); | |
28 } | |
29 | |
30 mojom::ViewClientPtr GetViewClient() { | |
31 return binding_.CreateInterfacePtrAndBind(); | |
32 } | |
33 | |
34 void QuitOnLoadingStateChange(base::RunLoop* loop) { | |
35 loop_ = loop; | |
36 } | |
37 | |
38 private: | |
39 // mojom::ViewClient: | |
40 void OpenURL(mojom::OpenURLParamsPtr params) override {} | |
41 void LoadingStateChanged(bool is_loading) override { | |
42 // Should see loading start, then stop. | |
43 if (++load_count_ == 2 && loop_) | |
44 loop_->Quit(); | |
45 } | |
46 void NavigationStateChanged(const GURL& url, | |
47 const std::string& title, | |
48 bool can_go_back, | |
49 bool can_go_forward) override {} | |
50 void LoadProgressChanged(double progress) override {} | |
51 void UpdateHoverURL(const GURL& url) override {} | |
52 void ViewCreated(mojom::ViewPtr, | |
53 mojom::ViewClientRequest, | |
54 bool, | |
55 const gfx::Rect&, | |
56 bool) override {} | |
57 void Close() override {} | |
58 void NavigationPending(mojom::NavigationEntryPtr entry) override {} | |
59 void NavigationCommitted( | |
60 mojom::NavigationCommittedDetailsPtr details, | |
61 int current_index) override {} | |
62 void NavigationEntryChanged(mojom::NavigationEntryPtr entry, | |
63 int entry_index) override {} | |
64 void NavigationListPruned(bool from_front, int count) override {} | |
65 | |
66 int load_count_ = 0; | |
67 mojo::Binding<mojom::ViewClient> binding_; | |
68 base::RunLoop* loop_ = nullptr; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(NavigationTest); | |
71 }; | |
72 | |
73 // See crbug.com/619523 | |
74 TEST_F(NavigationTest, DISABLED_Navigate) { | |
75 mojom::ViewFactoryPtr view_factory; | |
76 connector()->BindInterface("navigation", &view_factory); | |
77 | |
78 mojom::ViewPtr view; | |
79 view_factory->CreateView(GetViewClient(), MakeRequest(&view)); | |
80 view->NavigateTo(GURL("about:blank")); | |
81 | |
82 base::RunLoop loop; | |
83 QuitOnLoadingStateChange(&loop); | |
84 loop.Run(); | |
85 } | |
86 | |
87 } // namespace navigation | |
OLD | NEW |