diff options
author | sdefresne <sdefresne@chromium.org> | 2015-05-05 11:14:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-05 18:15:50 +0000 |
commit | f13c9fddb23eb7ee9acfe6a5c5907c389c3c6da3 (patch) | |
tree | 58d2bbd4742f300b7a56a098b893245821b614a1 /components/test | |
parent | 84809a6eb565c1bc54abb25c261f94ed2b4b3c83 (diff) | |
download | chromium_src-f13c9fddb23eb7ee9acfe6a5c5907c389c3c6da3.zip chromium_src-f13c9fddb23eb7ee9acfe6a5c5907c389c3c6da3.tar.gz chromium_src-f13c9fddb23eb7ee9acfe6a5c5907c389c3c6da3.tar.bz2 |
[History] Componentize history unittests
Remove dependencies on //content & //chrome that are no longer needed
and move unit tests into //components/history/core/browser.
Rename incorrectly named HistoryBackendDBTest and cie. to avoid name
collision with HistoryBackendTest.
Cleanup ZeroSuggestProvider to not use TestingProfile::DestroyTopSites
as it is not needed since it is registering a fake TopSites that does
not have the limitation of TopSitesImpl of only one instance per path.
Remove methods CreateTopSites/DestroyTopSites/BlockUntilTopSitesLoaded
from TestingProfile as they are no longer used.
Introduce //components/history/core/test/thumbnail{.cc,_ios.mm} to
abstract dependency on JPEG loading and run the tests on iOS.
Move tests data to //components/test/data/history.
BUG=370850, 227969
Review URL: https://codereview.chromium.org/1121473002
Cr-Commit-Position: refs/heads/master@{#328358}
Diffstat (limited to 'components/test')
19 files changed, 405 insertions, 0 deletions
diff --git a/components/test/data/history/Favicons.v3.sql b/components/test/data/history/Favicons.v3.sql new file mode 100644 index 0000000..1cdfc6f --- /dev/null +++ b/components/test/data/history/Favicons.v3.sql @@ -0,0 +1,16 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version3 +-- +-- .dump of a version 3 Favicons database. Version 3 contained a +-- table [thumbnails] which was migrated to [Top Sites] database, and +-- the [favicons] rows were referenced by the [urls.favicon_id] table +-- in this history database. See Favicons.v3.history.sql. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','3'); +INSERT INTO "meta" VALUES('last_compatible_version','3'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400'); +INSERT INTO "favicons" VALUES(2,'http://www.yahoo.com/favicon.ico',1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600'); +CREATE TABLE thumbnails(url_id INTEGER PRIMARY KEY,boring_score DOUBLE DEFAULT 1.0,good_clipping INTEGER DEFAULT 0,at_top INTEGER DEFAULT 0,last_updated INTEGER DEFAULT 0,data BLOB); +CREATE INDEX favicons_url ON favicons(url); +COMMIT; diff --git a/components/test/data/history/Favicons.v4.sql b/components/test/data/history/Favicons.v4.sql new file mode 100644 index 0000000..d2549bf --- /dev/null +++ b/components/test/data/history/Favicons.v4.sql @@ -0,0 +1,21 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version4 +-- +-- .dump of a version 4 Favicons database. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','4'); +INSERT INTO "meta" VALUES('last_compatible_version','4'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400',1); +INSERT INTO "favicons" VALUES(2,'http://www.google.com/touch.ico',1287424416,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',2); +INSERT INTO "favicons" VALUES(3,'http://www.yahoo.com/favicon.ico',1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',1); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +INSERT INTO "icon_mapping" VALUES(1,'http://google.com/',1); +INSERT INTO "icon_mapping" VALUES(2,'http://www.google.com/',1); +INSERT INTO "icon_mapping" VALUES(3,'http://www.google.com/',2); +INSERT INTO "icon_mapping" VALUES(4,'http://yahoo.com/',3); +INSERT INTO "icon_mapping" VALUES(5,'http://www.yahoo.com/',3); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +COMMIT; diff --git a/components/test/data/history/Favicons.v5.sql b/components/test/data/history/Favicons.v5.sql new file mode 100644 index 0000000..655d282 --- /dev/null +++ b/components/test/data/history/Favicons.v5.sql @@ -0,0 +1,21 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version5 +-- +-- .dump of a version 5 Favicons database. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','5'); +INSERT INTO "meta" VALUES('last_compatible_version','5'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400',1,'32 32'); +INSERT INTO "favicons" VALUES(2,'http://www.google.com/touch.ico',1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',2,'32 32'); +INSERT INTO "favicons" VALUES(3,'http://www.yahoo.com/favicon.ico',1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',1,'32 32'); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +INSERT INTO "icon_mapping" VALUES(1,'http://google.com/',1); +INSERT INTO "icon_mapping" VALUES(2,'http://www.google.com/',1); +INSERT INTO "icon_mapping" VALUES(3,'http://www.google.com/',2); +INSERT INTO "icon_mapping" VALUES(4,'http://yahoo.com/',3); +INSERT INTO "icon_mapping" VALUES(5,'http://www.yahoo.com/',3); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +COMMIT; diff --git a/components/test/data/history/Favicons.v6.sql b/components/test/data/history/Favicons.v6.sql new file mode 100644 index 0000000..c27125b --- /dev/null +++ b/components/test/data/history/Favicons.v6.sql @@ -0,0 +1,26 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version6 +-- +-- .dump of a version 6 Favicons database. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','6'); +INSERT INTO "meta" VALUES('last_compatible_version','6'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1,'32 32'); +INSERT INTO "favicons" VALUES(2,'http://www.google.com/touch.ico',2,'32 32'); +INSERT INTO "favicons" VALUES(3,'http://www.yahoo.com/favicon.ico',1,'32 32'); +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +INSERT INTO "favicon_bitmaps" VALUES(1,1,1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400',32,32); +INSERT INTO "favicon_bitmaps" VALUES(2,2,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32); +INSERT INTO "favicon_bitmaps" VALUES(3,3,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +INSERT INTO "icon_mapping" VALUES(1,'http://google.com/',1); +INSERT INTO "icon_mapping" VALUES(2,'http://www.google.com/',1); +INSERT INTO "icon_mapping" VALUES(3,'http://www.google.com/',2); +INSERT INTO "icon_mapping" VALUES(4,'http://yahoo.com/',3); +INSERT INTO "icon_mapping" VALUES(5,'http://www.yahoo.com/',3); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +COMMIT; diff --git a/components/test/data/history/Favicons.v7.sql b/components/test/data/history/Favicons.v7.sql new file mode 100644 index 0000000..8b0fd2c --- /dev/null +++ b/components/test/data/history/Favicons.v7.sql @@ -0,0 +1,26 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version7 +-- +-- .dump of a version 7 Favicons database. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','7'); +INSERT INTO "meta" VALUES('last_compatible_version','7'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1); +INSERT INTO "favicons" VALUES(2,'http://www.google.com/touch.ico',2); +INSERT INTO "favicons" VALUES(3,'http://www.yahoo.com/favicon.ico',1); +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +INSERT INTO "favicon_bitmaps" VALUES(1,1,1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400',32,32); +INSERT INTO "favicon_bitmaps" VALUES(2,2,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32); +INSERT INTO "favicon_bitmaps" VALUES(3,3,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +INSERT INTO "icon_mapping" VALUES(1,'http://google.com/',1); +INSERT INTO "icon_mapping" VALUES(2,'http://www.google.com/',1); +INSERT INTO "icon_mapping" VALUES(3,'http://www.google.com/',2); +INSERT INTO "icon_mapping" VALUES(4,'http://yahoo.com/',3); +INSERT INTO "icon_mapping" VALUES(5,'http://www.yahoo.com/',3); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +COMMIT; diff --git a/components/test/data/history/Favicons.v8.sql b/components/test/data/history/Favicons.v8.sql new file mode 100644 index 0000000..0905172 --- /dev/null +++ b/components/test/data/history/Favicons.v8.sql @@ -0,0 +1,26 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.Version8 +-- +-- .dump of a version 8 Favicons database. +BEGIN TRANSACTION; +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','8'); +INSERT INTO "meta" VALUES('last_compatible_version','8'); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1); +INSERT INTO "favicons" VALUES(1,'http://www.google.com/favicon.ico',1); +INSERT INTO "favicons" VALUES(2,'http://www.google.com/touch.ico',2); +INSERT INTO "favicons" VALUES(3,'http://www.yahoo.com/favicon.ico',1); +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0,last_requested INTEGER DEFAULT 0); +INSERT INTO "favicon_bitmaps" VALUES(1,1,1287424416,X'313233343631303233353631323033393437353136333435313635393133343837313034373831323336343931363534313932333435313932333435313233343931333400',32,32,0); +INSERT INTO "favicon_bitmaps" VALUES(2,2,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32,1387424428); +INSERT INTO "favicon_bitmaps" VALUES(3,3,1287424428,X'676F6977756567727172636F6D697A71797A6B6A616C697462616878666A7974727176707165726F6963786D6E6C6B686C7A756E616378616E65766961777274786379776867656600',32,32,0); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +INSERT INTO "icon_mapping" VALUES(1,'http://google.com/',1); +INSERT INTO "icon_mapping" VALUES(2,'http://www.google.com/',1); +INSERT INTO "icon_mapping" VALUES(3,'http://www.google.com/',2); +INSERT INTO "icon_mapping" VALUES(4,'http://yahoo.com/',3); +INSERT INTO "icon_mapping" VALUES(5,'http://www.yahoo.com/',3); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +COMMIT; diff --git a/components/test/data/history/HistoryNoDuration b/components/test/data/history/HistoryNoDuration Binary files differnew file mode 100644 index 0000000..3d00e5a --- /dev/null +++ b/components/test/data/history/HistoryNoDuration diff --git a/components/test/data/history/HistoryNoSource b/components/test/data/history/HistoryNoSource Binary files differnew file mode 100644 index 0000000..19b4b8e --- /dev/null +++ b/components/test/data/history/HistoryNoSource diff --git a/components/test/data/history/History_with_starred b/components/test/data/history/History_with_starred Binary files differnew file mode 100644 index 0000000..4b913b2 --- /dev/null +++ b/components/test/data/history/History_with_starred diff --git a/components/test/data/history/thumbnail_wild/Favicons.corrupt_meta.disable b/components/test/data/history/thumbnail_wild/Favicons.corrupt_meta.disable new file mode 100644 index 0000000..05e46ef --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.corrupt_meta.disable @@ -0,0 +1,28 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- [meta] table has first column [oey] instead of [key] (single-bit +-- error). Database consistent with v6, but that may just mean that +-- v6 code was when attempting to work with an empty database with a +-- broken [meta] table. Multiple reports from the same clientid have +-- seen this, so the broken [meta] is almost certainly on disk. +-- +-- TODO(shess): This is clearly low-priority BUT the general class of +-- problem where the schema is wrong should be handled. I suspect the +-- final solution will be to Raze() if the database contains [meta] +-- but the version cannot be fetched from it, or failing some other +-- validity metric. +BEGIN TRANSACTION; + +CREATE TABLE meta(oey LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); + +CREATE TABLE "favicons" (id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE INDEX favicons_url ON favicons(url); + +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v2.init.sql b/components/test/data/history/thumbnail_wild/Favicons.v2.init.sql new file mode 100644 index 0000000..53b6b73 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v2.init.sql @@ -0,0 +1,27 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 2 schema found in the wild by error diagnostics. +-- The schema was failing to migrate because the current-version +-- tables were being created before the migration code was called, +-- resulting in the migration code attempting to add columns which +-- already existed (see http://crbug.com/273203 ). +-- +-- Should be razed by the deprecation code. +BEGIN TRANSACTION; + +-- [meta] and [thumbnails] are expected tables. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','2'); +INSERT INTO "meta" VALUES('last_compatible_version','2'); +CREATE TABLE thumbnails (url LONGVARCHAR PRIMARY KEY,url_rank INTEGER ,title LONGVARCHAR,thumbnail BLOB,redirects LONGVARCHAR,boring_score DOUBLE DEFAULT 1.0, good_clipping INTEGER DEFAULT 0, at_top INTEGER DEFAULT 0, last_updated INTEGER DEFAULT 0, load_completed INTEGER DEFAULT 0); + +-- Tables optimistically created by Init(). +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1); +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); +CREATE INDEX favicons_url ON favicons(url); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v3.init.sql b/components/test/data/history/thumbnail_wild/Favicons.v3.init.sql new file mode 100644 index 0000000..3453860 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v3.init.sql @@ -0,0 +1,36 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 3 schema found in the wild by error diagnostics. +-- The schema was failing to migrate because the current-version +-- tables were being created before the migration code was called, +-- resulting in the migration code attempting to add columns which +-- already existed (see http://crbug.com/273203 ). +-- +-- Should be razed by the deprecation code. +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','3'); +INSERT INTO "meta" VALUES('last_compatible_version','3'); + +-- [thumbnails] is optional for v3, but was not seen in any diagnostic +-- results. + +-- [favicons] was present in v3, but [icon_type] is a v4 column. +CREATE TABLE favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] is a v4 table. Some cases didn't have the indices, +-- possibly because the migration code didn't create indices (they +-- were created optimistically on next run). +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +-- [favicon_bitmaps] is a v6 table. Some diagnostic results did not +-- contain this table. +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v4.init.sql b/components/test/data/history/thumbnail_wild/Favicons.v4.init.sql new file mode 100644 index 0000000..6c5738e --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v4.init.sql @@ -0,0 +1,32 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 3 and 4 schema found in the wild by error +-- diagnostics. Combined because they were the same except for +-- version. The schema was failing to migrate because the migration +-- code encountered a table which appeared to already be migrated. +-- +-- Should be razed by the deprecation code. +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','4'); +INSERT INTO "meta" VALUES('last_compatible_version','4'); + +-- This version of [favicons] implies v6 code. Other versions are +-- missing [size], implying v7. Either way, since v4 had the table, +-- migration must have run, but the atomic update of version somehow +-- failed. +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] is a v4 table. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +-- [favicon_bitmaps] is a v6 table. +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type.sql b/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type.sql new file mode 100644 index 0000000..a00a439 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type.sql @@ -0,0 +1,24 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 5 schema found in the wild by error diagnostics. +-- The schema failed to open because the v3 [favicons] table is +-- missing [icon_type]. +-- +-- Init() should clean up with RazeAndClose(). +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','5'); +INSERT INTO "meta" VALUES('last_compatible_version','5'); + +-- v3 [favicons] (missing [icon_type]), but v5 database. +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] consistent with v5. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type2.sql b/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type2.sql new file mode 100644 index 0000000..25ceded --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v5.icon_type2.sql @@ -0,0 +1,25 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 5 schema found in the wild by error diagnostics. +-- The schema failed to open because the v3 [favicons] table is +-- missing [icon_type]. How this schema formed is unclear, as it has +-- evidence of a migration from after version 5. +-- +-- Init() should clean up with RazeAndClose(). +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','5'); +INSERT INTO "meta" VALUES('last_compatible_version','5'); + +-- v3 [favicons] (has [image_data]), but with v5 attributes (has [sizes]). +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB, sizes LONGVARCHAR); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] consistent with v5. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v5.init.sql b/components/test/data/history/thumbnail_wild/Favicons.v5.init.sql new file mode 100644 index 0000000..c92a110 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v5.init.sql @@ -0,0 +1,35 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 5 schema found in the wild by error diagnostics. +-- The schema failed migrations because of an unexpected +-- [temp_favicons] table (see http://crbug.com/272519 ). +-- +-- Init() has been modified to drop these tables before migration. +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','5'); +INSERT INTO "meta" VALUES('last_compatible_version','5'); + +-- This version of [favicons] is consistent with v5. +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] consistent with v5. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +-- [favicon_bitmaps] is a v6 table created by Init() before version +-- check. This probably is only in memory (not committed). +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); + +-- Presence of these tables is consistent with an aborted attempt to +-- clear history. Prior to r217993, that code was not contained in a +-- transaction (or possibly there was a non-atomic update). +CREATE TABLE temp_favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE TABLE temp_icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v5.sizes.sql b/components/test/data/history/thumbnail_wild/Favicons.v5.sizes.sql new file mode 100644 index 0000000..6dfa9e9 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v5.sizes.sql @@ -0,0 +1,24 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 5 schema found in the wild by error diagnostics. +-- The schema failed to open because the v3 [favicons] table is +-- missing [sizes]. +-- +-- Init() should clean up with RazeAndClose(). +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','5'); +INSERT INTO "meta" VALUES('last_compatible_version','5'); + +-- v4 [favicons] (missing [sizes]), but v5 database. +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,icon_type INTEGER DEFAULT 1); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] consistent with v5. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/Favicons.v6.init.sql b/components/test/data/history/thumbnail_wild/Favicons.v6.init.sql new file mode 100644 index 0000000..3014c37 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/Favicons.v6.init.sql @@ -0,0 +1,36 @@ +-- unit_tests --gtest_filter=ThumbnailDatabaseTest.WildSchema +-- +-- Based on version 6 schema found in the wild by error diagnostics. +-- The schema failed migrations because of unexpected +-- [temp_favicons] table (see http://crbug.com/272519 ). +-- +-- Init() has been modified to drop these tables. +-- TODO(shess): Should this case contain data? +BEGIN TRANSACTION; + +-- [meta] is expected. +CREATE TABLE meta(key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY,value LONGVARCHAR); +INSERT INTO "meta" VALUES('version','6'); +INSERT INTO "meta" VALUES('last_compatible_version','6'); + +-- This version of [favicons] is consistent with v6. +CREATE TABLE "favicons"(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE INDEX favicons_url ON favicons(url); + +-- [icon_mapping] consistent with v6. +CREATE TABLE icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE INDEX icon_mapping_icon_id_idx ON icon_mapping(icon_id); +CREATE INDEX icon_mapping_page_url_idx ON icon_mapping(page_url); + +-- [favicon_bitmaps] consistent with v6. +CREATE TABLE favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); +CREATE INDEX favicon_bitmaps_icon_id ON favicon_bitmaps(icon_id); + +-- Presence of these tables is consistent with an aborted attempt to +-- clear history. Prior to r217993, that code was not contained in a +-- transaction (or possibly there was a non-atomic update). +CREATE TABLE temp_favicons(id INTEGER PRIMARY KEY,url LONGVARCHAR NOT NULL,icon_type INTEGER DEFAULT 1,sizes LONGVARCHAR); +CREATE TABLE temp_icon_mapping(id INTEGER PRIMARY KEY,page_url LONGVARCHAR NOT NULL,icon_id INTEGER); +CREATE TABLE temp_favicon_bitmaps(id INTEGER PRIMARY KEY,icon_id INTEGER NOT NULL,last_updated INTEGER DEFAULT 0,image_data BLOB,width INTEGER DEFAULT 0,height INTEGER DEFAULT 0); + +COMMIT; diff --git a/components/test/data/history/thumbnail_wild/README b/components/test/data/history/thumbnail_wild/README new file mode 100644 index 0000000..efe0e53 --- /dev/null +++ b/components/test/data/history/thumbnail_wild/README @@ -0,0 +1,2 @@ +These files represent actual schema found in problem databases in the +wild. |