summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/mojo
diff options
context:
space:
mode:
authorsammc <sammc@chromium.org>2015-02-09 17:10:15 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-10 01:10:55 +0000
commit5cc0cb8eae54f6b228f390c5e2e48ba76764e564 (patch)
treeda1a3f2d50455a381458c7518af654b2859af33f /extensions/renderer/mojo
parent02d9ead993610863dfff6dd600cfc464db35d0ac (diff)
downloadchromium_src-5cc0cb8eae54f6b228f390c5e2e48ba76764e564.zip
chromium_src-5cc0cb8eae54f6b228f390c5e2e48ba76764e564.tar.gz
chromium_src-5cc0cb8eae54f6b228f390c5e2e48ba76764e564.tar.bz2
Add a JS stash client.
The stash client allows clients to stash services during renderer shut-down and retrieve them during renderer start-up. BUG=389016 Review URL: https://codereview.chromium.org/661423007 Cr-Commit-Position: refs/heads/master@{#315463}
Diffstat (limited to 'extensions/renderer/mojo')
-rw-r--r--extensions/renderer/mojo/stash_client_unittest.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/extensions/renderer/mojo/stash_client_unittest.cc b/extensions/renderer/mojo/stash_client_unittest.cc
new file mode 100644
index 0000000..ec3dc3f
--- /dev/null
+++ b/extensions/renderer/mojo/stash_client_unittest.cc
@@ -0,0 +1,49 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <vector>
+
+#include "extensions/browser/mojo/stash_backend.h"
+#include "extensions/common/mojo/stash.mojom.h"
+#include "extensions/renderer/api_test_base.h"
+#include "gin/dictionary.h"
+#include "grit/extensions_renderer_resources.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/lib/message_builder.h"
+
+// A test launcher for tests for the stash client defined in
+// extensions/test/data/stash_client_unittest.js.
+
+namespace extensions {
+class StashClientTest : public ApiTestBase {
+ public:
+ StashClientTest() {}
+
+ void SetUp() override {
+ ApiTestBase::SetUp();
+ stash_backend_.reset(new StashBackend(base::Closure()));
+ PrepareEnvironment(api_test_env());
+ }
+
+ void PrepareEnvironment(ApiTestEnvironment* env) {
+ env->service_provider()->AddService(base::Bind(
+ &StashBackend::BindToRequest, base::Unretained(stash_backend_.get())));
+ }
+
+ scoped_ptr<StashBackend> stash_backend_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(StashClientTest);
+};
+
+// Test that stashing and restoring work correctly.
+TEST_F(StashClientTest, StashAndRestore) {
+ ASSERT_NO_FATAL_FAILURE(RunTest("stash_client_unittest.js", "testStash"));
+ env()->context()->DispatchOnUnloadEvent();
+ scoped_ptr<ModuleSystemTestEnvironment> restore_test_env(CreateEnvironment());
+ ApiTestEnvironment restore_environment(restore_test_env.get());
+ PrepareEnvironment(&restore_environment);
+ restore_environment.RunTest("stash_client_unittest.js", "testRetrieve");
+}
+
+} // namespace extensions