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.
7 #include "extensions/browser/mojo/stash_backend.h"
8 #include "extensions/common/mojo/stash.mojom.h"
9 #include "extensions/renderer/api_test_base.h"
10 #include "gin/dictionary.h"
11 #include "grit/extensions_renderer_resources.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/lib/message_builder.h"
14 // A test launcher for tests for the stash client defined in
15 // extensions/test/data/stash_client_unittest.js.
17 namespace extensions
{
18 class StashClientTest
: public ApiTestBase
{
22 void SetUp() override
{
24 stash_backend_
.reset(new StashBackend(base::Closure()));
25 PrepareEnvironment(api_test_env());
28 void PrepareEnvironment(ApiTestEnvironment
* env
) {
29 env
->service_provider()->AddService(base::Bind(
30 &StashBackend::BindToRequest
, base::Unretained(stash_backend_
.get())));
33 scoped_ptr
<StashBackend
> stash_backend_
;
36 DISALLOW_COPY_AND_ASSIGN(StashClientTest
);
39 // Test that stashing and restoring work correctly.
40 TEST_F(StashClientTest
, StashAndRestore
) {
41 ASSERT_NO_FATAL_FAILURE(RunTest("stash_client_unittest.js", "testStash"));
42 env()->context()->DispatchOnUnloadEvent();
43 scoped_ptr
<ModuleSystemTestEnvironment
> restore_test_env(CreateEnvironment());
44 ApiTestEnvironment
restore_environment(restore_test_env
.get());
45 PrepareEnvironment(&restore_environment
);
46 restore_environment
.RunTest("stash_client_unittest.js", "testRetrieve");
49 } // namespace extensions