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

Unified Diff: services/navigation/navigation_unittest.cc

Issue 2046723002: Add navigation client lib for convenience (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@target
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/navigation/BUILD.gn ('k') | services/navigation/public/cpp/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/navigation/navigation_unittest.cc
diff --git a/services/navigation/navigation_unittest.cc b/services/navigation/navigation_unittest.cc
index c21ec32395bacd2614d3ba8734db2ebae2702e8c..50cdc7992017fb55022d3bf0f52223bcbfa23e3e 100644
--- a/services/navigation/navigation_unittest.cc
+++ b/services/navigation/navigation_unittest.cc
@@ -6,6 +6,8 @@
#include "base/macros.h"
#include "base/run_loop.h"
+#include "services/navigation/public/cpp/view.h"
+#include "services/navigation/public/cpp/view_delegate.h"
#include "services/navigation/public/interfaces/view.mojom.h"
#include "services/shell/public/cpp/shell_client.h"
#include "services/shell/public/cpp/shell_test.h"
@@ -13,49 +15,43 @@
namespace navigation {
class NavigationTest : public shell::test::ShellTest,
- public mojom::ViewClient {
+ public ViewDelegate {
public:
NavigationTest()
- : shell::test::ShellTest("exe:navigation_unittests"),
- binding_(this) {}
+ : shell::test::ShellTest("exe:navigation_unittests") {}
~NavigationTest() override {}
protected:
- void SetUp() override {
- shell::test::ShellTest::SetUp();
- window_manager_connection_ = connector()->Connect("mojo:test_wm");
- }
+ void SetUp() override {
+ shell::test::ShellTest::SetUp();
+ window_manager_connection_ = connector()->Connect("mojo:test_wm");
- mojom::ViewClientPtr GetViewClient() {
- return binding_.CreateInterfacePtrAndBind();
+ view_.reset(new View(this));
+ mojom::ViewFactoryPtr view_factory;
+ connector()->ConnectToInterface("exe:navigation", &view_factory);
+ view_->Init(std::move(view_factory));
+ }
+ void TearDown() override {
+ view_.reset();
+ shell::test::ShellTest::TearDown();
}
void QuitOnLoadingStateChange(base::RunLoop* loop) {
loop_ = loop;
}
+ View* view() { return view_.get(); }
+
private:
- // mojom::ViewClient:
+ // ViewDelegate:
void LoadingStateChanged(bool is_loading) override {
// Should see loading start, then stop.
if (++load_count_ == 2 && loop_)
loop_->Quit();
}
- void NavigationStateChanged(const GURL& url,
- const mojo::String& title,
- bool can_go_back,
- bool can_go_forward) override {}
- void LoadProgressChanged(double progress) override {}
- void UpdateHoverURL(const GURL& url) override {}
- void ViewCreated(mojom::ViewPtr,
- mojom::ViewClientRequest,
- bool,
- const gfx::Rect&,
- bool) override {}
- void Close() override {}
int load_count_ = 0;
- mojo::Binding<mojom::ViewClient> binding_;
+ std::unique_ptr<View> view_;
base::RunLoop* loop_ = nullptr;
std::unique_ptr<shell::Connection> window_manager_connection_;
@@ -63,12 +59,7 @@ class NavigationTest : public shell::test::ShellTest,
};
TEST_F(NavigationTest, Navigate) {
- mojom::ViewFactoryPtr view_factory;
- connector()->ConnectToInterface("exe:navigation", &view_factory);
-
- mojom::ViewPtr view;
- view_factory->CreateView(GetViewClient(), GetProxy(&view));
- view->NavigateTo(GURL("about:blank"));
+ view()->NavigateTo(GURL("about:blank"));
base::RunLoop loop;
QuitOnLoadingStateChange(&loop);
« no previous file with comments | « services/navigation/BUILD.gn ('k') | services/navigation/public/cpp/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698