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

Unified Diff: content/browser/media/webrtc_identity_store_unittest.cc

Issue 289343005: Do not CHECK on the result of Sql::Statement::Run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 | « content/browser/media/webrtc_identity_store_backend.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/webrtc_identity_store_unittest.cc
diff --git a/content/browser/media/webrtc_identity_store_unittest.cc b/content/browser/media/webrtc_identity_store_unittest.cc
index 85bd18f37689d58495fc482583ce4da36c8abb51..586559f2c05d3d6d3abf21795846d4dc69962f2c 100644
--- a/content/browser/media/webrtc_identity_store_unittest.cc
+++ b/content/browser/media/webrtc_identity_store_unittest.cc
@@ -10,6 +10,8 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "content/public/test/test_utils.h"
#include "net/base/net_errors.h"
+#include "sql/connection.h"
+#include "sql/test/test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -343,4 +345,35 @@ TEST_F(WebRTCIdentityStoreTest, IdentityPersistentAcrossRestart) {
EXPECT_EQ(key_1, key_2);
}
+TEST_F(WebRTCIdentityStoreTest, HandleDBErrors) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ Restart(temp_dir.path());
+
+ bool completed_1 = false;
+ std::string cert_1, key_1;
+
+ // Creates an identity.
+ RequestIdentityAndRunUtilIdle(kFakeOrigin,
+ kFakeIdentityName1,
+ kFakeCommonName1,
+ &completed_1,
+ &cert_1,
+ &key_1);
+
+ // Make the table corrupted.
+ base::FilePath db_path =
+ temp_dir.path().Append(FILE_PATH_LITERAL("WebRTCIdentityStore"));
+ EXPECT_TRUE(sql::test::CorruptSizeInHeader(db_path));
+
+ // Reset to commit the DB changes, which should fail and not crash.
+ webrtc_identity_store_ = NULL;
+ RunUntilIdle();
+
+ // Verifies the corrupted table was razed.
+ scoped_ptr<sql::Connection> db(new sql::Connection());
+ EXPECT_TRUE(db->Open(db_path));
+ EXPECT_EQ(0U, sql::test::CountSQLTables(db.get()));
+}
+
} // namespace content
« no previous file with comments | « content/browser/media/webrtc_identity_store_backend.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698