OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "services/navigation/public/interfaces/view.mojom.h" | 9 #include "services/navigation/public/interfaces/view.mojom.h" |
10 #include "services/shell/public/cpp/shell_client.h" | 10 #include "services/shell/public/cpp/shell_client.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 loop_ = loop; | 34 loop_ = loop; |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 // mojom::ViewClient: | 38 // mojom::ViewClient: |
39 void LoadingStateChanged(bool is_loading) override { | 39 void LoadingStateChanged(bool is_loading) override { |
40 // Should see loading start, then stop. | 40 // Should see loading start, then stop. |
41 if (++load_count_ == 2 && loop_) | 41 if (++load_count_ == 2 && loop_) |
42 loop_->Quit(); | 42 loop_->Quit(); |
43 } | 43 } |
44 void NavigationStateChanged(const GURL& url, | |
45 const mojo::String& title, | |
46 bool can_go_back, | |
47 bool can_go_forward) override {} | |
48 void LoadProgressChanged(double progress) override {} | |
49 void ViewCreated(mojom::ViewPtr, | |
50 mojom::ViewClientRequest, | |
51 bool, | |
52 mojo::RectPtr, | |
53 bool) override {} | |
54 void Close() override {} | |
55 | 44 |
56 int load_count_ = 0; | 45 int load_count_ = 0; |
57 mojo::Binding<mojom::ViewClient> binding_; | 46 mojo::Binding<mojom::ViewClient> binding_; |
58 base::RunLoop* loop_ = nullptr; | 47 base::RunLoop* loop_ = nullptr; |
59 std::unique_ptr<shell::Connection> window_manager_connection_; | 48 std::unique_ptr<shell::Connection> window_manager_connection_; |
60 | 49 |
61 DISALLOW_COPY_AND_ASSIGN(NavigationTest); | 50 DISALLOW_COPY_AND_ASSIGN(NavigationTest); |
62 }; | 51 }; |
63 | 52 |
64 TEST_F(NavigationTest, Navigate) { | 53 TEST_F(NavigationTest, LoadURL) { |
65 mojom::ViewFactoryPtr view_factory; | 54 mojom::ViewFactoryPtr view_factory; |
66 connector()->ConnectToInterface("exe:navigation", &view_factory); | 55 connector()->ConnectToInterface("exe:navigation", &view_factory); |
67 | 56 |
68 mojom::ViewPtr view; | 57 mojom::ViewPtr view; |
69 view_factory->CreateView(GetViewClient(), GetProxy(&view)); | 58 view_factory->CreateView(GetViewClient(), GetProxy(&view)); |
70 view->NavigateTo(GURL("about:blank")); | 59 view->LoadUrl(GURL("about:blank")); |
71 | 60 |
72 base::RunLoop loop; | 61 base::RunLoop loop; |
73 QuitOnLoadingStateChange(&loop); | 62 QuitOnLoadingStateChange(&loop); |
74 loop.Run(); | 63 loop.Run(); |
75 } | 64 } |
76 | 65 |
77 } // namespace navigation | 66 } // namespace navigation |
OLD | NEW |