| Index: content/browser/dom_storage/local_storage_context_mojo_unittest.cc
|
| diff --git a/content/browser/dom_storage/local_storage_context_mojo_unittest.cc b/content/browser/dom_storage/local_storage_context_mojo_unittest.cc
|
| index 33db77ce8fceb280e24febebc21bf7434626e73f..41b4e83fd63ef30889679b83f072298a89601a66 100644
|
| --- a/content/browser/dom_storage/local_storage_context_mojo_unittest.cc
|
| +++ b/content/browser/dom_storage/local_storage_context_mojo_unittest.cc
|
| @@ -25,6 +25,8 @@
|
| #include "services/service_manager/public/cpp/service_test.h"
|
| #include "services/service_manager/public/interfaces/service_factory.mojom.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| +#include "third_party/leveldatabase/env_chromium.h"
|
| +#include "third_party/leveldatabase/src/include/leveldb/db.h"
|
|
|
| using leveldb::StdStringToUint8Vector;
|
| using leveldb::Uint8VectorToStdString;
|
| @@ -732,4 +734,56 @@ TEST_F(LocalStorageContextMojoTestWithService, MAYBE_OnDisk) {
|
| EXPECT_EQ(value, result);
|
| }
|
|
|
| +// Enable when http://crbug.com/677194 is fixed and ServiceTest works
|
| +// correctly on Android.
|
| +#if defined(OS_ANDROID)
|
| +#define MAYBE_InvalidVersionOnDisk DISABLED_InvalidVersionOnDisk
|
| +#else
|
| +#define MAYBE_InvalidVersionOnDisk InvalidVersionOnDisk
|
| +#endif
|
| +TEST_F(LocalStorageContextMojoTestWithService, MAYBE_InvalidVersionOnDisk) {
|
| + base::FilePath test_path(FILE_PATH_LITERAL("test_path"));
|
| +
|
| + // Create context and add some data to it.
|
| + auto context =
|
| + base::MakeUnique<LocalStorageContextMojo>(connector(), test_path);
|
| + auto key = StdStringToUint8Vector("key");
|
| + auto value = StdStringToUint8Vector("value");
|
| +
|
| + DoTestPut(context.get(), key, value);
|
| + std::vector<uint8_t> result;
|
| + EXPECT_TRUE(DoTestGet(context.get(), key, &result));
|
| + EXPECT_EQ(value, result);
|
| +
|
| + context.reset();
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + {
|
| + // Mess up version number in database.
|
| + leveldb_env::ChromiumEnv env;
|
| + leveldb::DB* db = nullptr;
|
| + leveldb::Options options;
|
| + options.env = &env;
|
| + base::FilePath db_path = temp_path().Append(test_path).Append("leveldb");
|
| + ASSERT_TRUE(leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), &db).ok());
|
| + std::unique_ptr<leveldb::DB> db_owner(db);
|
| + ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok());
|
| + }
|
| +
|
| + // Make sure data is gone.
|
| + context = base::MakeUnique<LocalStorageContextMojo>(connector(), test_path);
|
| + EXPECT_FALSE(DoTestGet(context.get(), key, &result));
|
| +
|
| + // Write data again.
|
| + DoTestPut(context.get(), key, value);
|
| +
|
| + context.reset();
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + // Data should have been preserved now.
|
| + context = base::MakeUnique<LocalStorageContextMojo>(connector(), test_path);
|
| + EXPECT_TRUE(DoTestGet(context.get(), key, &result));
|
| + EXPECT_EQ(value, result);
|
| +}
|
| +
|
| } // namespace content
|
|
|