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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « content/browser/media/webrtc_identity_store_backend.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/test/sequenced_worker_pool_owner.h" 8 #include "base/test/sequenced_worker_pool_owner.h"
9 #include "content/browser/media/webrtc_identity_store.h" 9 #include "content/browser/media/webrtc_identity_store.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "sql/connection.h"
14 #include "sql/test/test_helpers.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include "url/gurl.h" 16 #include "url/gurl.h"
15 17
16 namespace content { 18 namespace content {
17 19
18 static const char* kFakeOrigin = "http://foo.com"; 20 static const char* kFakeOrigin = "http://foo.com";
19 static const char* kFakeIdentityName1 = "name1"; 21 static const char* kFakeIdentityName1 = "name1";
20 static const char* kFakeIdentityName2 = "name2"; 22 static const char* kFakeIdentityName2 = "name2";
21 static const char* kFakeCommonName1 = "cname1"; 23 static const char* kFakeCommonName1 = "cname1";
22 static const char* kFakeCommonName2 = "cname2"; 24 static const char* kFakeCommonName2 = "cname2";
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 kFakeIdentityName1, 338 kFakeIdentityName1,
337 kFakeCommonName1, 339 kFakeCommonName1,
338 &completed_2, 340 &completed_2,
339 &cert_2, 341 &cert_2,
340 &key_2); 342 &key_2);
341 EXPECT_TRUE(completed_2); 343 EXPECT_TRUE(completed_2);
342 EXPECT_EQ(cert_1, cert_2); 344 EXPECT_EQ(cert_1, cert_2);
343 EXPECT_EQ(key_1, key_2); 345 EXPECT_EQ(key_1, key_2);
344 } 346 }
345 347
348 TEST_F(WebRTCIdentityStoreTest, HandleDBErrors) {
349 base::ScopedTempDir temp_dir;
350 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
351 Restart(temp_dir.path());
352
353 bool completed_1 = false;
354 std::string cert_1, key_1;
355
356 // Creates an identity.
357 RequestIdentityAndRunUtilIdle(kFakeOrigin,
358 kFakeIdentityName1,
359 kFakeCommonName1,
360 &completed_1,
361 &cert_1,
362 &key_1);
363
364 // Make the table corrupted.
365 base::FilePath db_path =
366 temp_dir.path().Append(FILE_PATH_LITERAL("WebRTCIdentityStore"));
367 EXPECT_TRUE(sql::test::CorruptSizeInHeader(db_path));
368
369 // Reset to commit the DB changes, which should fail and not crash.
370 webrtc_identity_store_ = NULL;
371 RunUntilIdle();
372
373 // Verifies the corrupted table was razed.
374 scoped_ptr<sql::Connection> db(new sql::Connection());
375 EXPECT_TRUE(db->Open(db_path));
376 EXPECT_EQ(0U, sql::test::CountSQLTables(db.get()));
377 }
378
346 } // namespace content 379 } // namespace content
OLDNEW
« 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