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

Side by Side Diff: chrome/browser/history/history_backend_unittest.cc

Issue 151168: Moved typedef of RedirectList from HistoryService class to history namespace.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/gfx/jpeg_codec.h" 7 #include "base/gfx/jpeg_codec.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public: 53 public:
54 HistoryBackendTest() : bookmark_model_(NULL), loaded_(false) {} 54 HistoryBackendTest() : bookmark_model_(NULL), loaded_(false) {}
55 virtual ~HistoryBackendTest() { 55 virtual ~HistoryBackendTest() {
56 } 56 }
57 57
58 protected: 58 protected:
59 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure. 59 scoped_refptr<HistoryBackend> backend_; // Will be NULL on init failure.
60 scoped_ptr<InMemoryHistoryBackend> mem_backend_; 60 scoped_ptr<InMemoryHistoryBackend> mem_backend_;
61 61
62 void AddRedirectChain(const char* sequence[], int page_id) { 62 void AddRedirectChain(const char* sequence[], int page_id) {
63 HistoryService::RedirectList redirects; 63 history::RedirectList redirects;
64 for (int i = 0; sequence[i] != NULL; ++i) 64 for (int i = 0; sequence[i] != NULL; ++i)
65 redirects.push_back(GURL(sequence[i])); 65 redirects.push_back(GURL(sequence[i]));
66 66
67 int int_scope = 1; 67 int int_scope = 1;
68 void* scope = 0; 68 void* scope = 0;
69 memcpy(&scope, &int_scope, sizeof(int_scope)); 69 memcpy(&scope, &int_scope, sizeof(int_scope));
70 scoped_refptr<history::HistoryAddPageArgs> request( 70 scoped_refptr<history::HistoryAddPageArgs> request(
71 new history::HistoryAddPageArgs( 71 new history::HistoryAddPageArgs(
72 redirects.back(), Time::Now(), scope, page_id, GURL(), 72 redirects.back(), Time::Now(), scope, page_id, GURL(),
73 redirects, PageTransition::LINK, true)); 73 redirects, PageTransition::LINK, true));
74 backend_->AddPage(request); 74 backend_->AddPage(request);
75 } 75 }
76 76
77 // Adds CLIENT_REDIRECT page transition. 77 // Adds CLIENT_REDIRECT page transition.
78 // |url1| is the source URL and |url2| is the destination. 78 // |url1| is the source URL and |url2| is the destination.
79 // |did_replace| is true if the transition is non-user initiated and the 79 // |did_replace| is true if the transition is non-user initiated and the
80 // navigation entry for |url2| has replaced that for |url1|. The possibly 80 // navigation entry for |url2| has replaced that for |url1|. The possibly
81 // updated transition code of the visit records for |url1| and |url2| is 81 // updated transition code of the visit records for |url1| and |url2| is
82 // returned by filling in |*transition1| and |*transition2|, respectively. 82 // returned by filling in |*transition1| and |*transition2|, respectively.
83 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace, 83 void AddClientRedirect(const GURL& url1, const GURL& url2, bool did_replace,
84 int* transition1, int* transition2) { 84 int* transition1, int* transition2) {
85 void* const dummy_scope = reinterpret_cast<void*>(0x87654321); 85 void* const dummy_scope = reinterpret_cast<void*>(0x87654321);
86 HistoryService::RedirectList redirects; 86 history::RedirectList redirects;
87 if (url1.is_valid()) 87 if (url1.is_valid())
88 redirects.push_back(url1); 88 redirects.push_back(url1);
89 if (url2.is_valid()) 89 if (url2.is_valid())
90 redirects.push_back(url2); 90 redirects.push_back(url2);
91 scoped_refptr<HistoryAddPageArgs> request( 91 scoped_refptr<HistoryAddPageArgs> request(
92 new HistoryAddPageArgs(url2, base::Time(), dummy_scope, 0, url1, 92 new HistoryAddPageArgs(url2, base::Time(), dummy_scope, 0, url1,
93 redirects, PageTransition::CLIENT_REDIRECT, did_replace)); 93 redirects, PageTransition::CLIENT_REDIRECT, did_replace));
94 backend_->AddPage(request); 94 backend_->AddPage(request);
95 95
96 *transition1 = getTransition(url1); 96 *transition1 = getTransition(url1);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // Tests a handful of assertions for a navigation with a type of 431 // Tests a handful of assertions for a navigation with a type of
432 // KEYWORD_GENERATED. 432 // KEYWORD_GENERATED.
433 TEST_F(HistoryBackendTest, KeywordGenerated) { 433 TEST_F(HistoryBackendTest, KeywordGenerated) {
434 ASSERT_TRUE(backend_.get()); 434 ASSERT_TRUE(backend_.get());
435 435
436 GURL url("http://google.com"); 436 GURL url("http://google.com");
437 437
438 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1); 438 Time visit_time = Time::Now() - base::TimeDelta::FromDays(1);
439 scoped_refptr<HistoryAddPageArgs> request( 439 scoped_refptr<HistoryAddPageArgs> request(
440 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), 440 new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(),
441 HistoryService::RedirectList(), 441 history::RedirectList(),
442 PageTransition::KEYWORD_GENERATED, false)); 442 PageTransition::KEYWORD_GENERATED, false));
443 backend_->AddPage(request); 443 backend_->AddPage(request);
444 444
445 // A row should have been added for the url. 445 // A row should have been added for the url.
446 URLRow row; 446 URLRow row;
447 URLID url_id = backend_->db()->GetRowForURL(url, &row); 447 URLID url_id = backend_->db()->GetRowForURL(url, &row);
448 ASSERT_NE(0, url_id); 448 ASSERT_NE(0, url_id);
449 449
450 // The typed count should be 1. 450 // The typed count should be 1.
451 ASSERT_EQ(1, row.typed_count()); 451 ASSERT_EQ(1, row.typed_count());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END); 495 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END);
496 496
497 // Non-user initiated redirect to page C. 497 // Non-user initiated redirect to page C.
498 GURL url_c("http://google.com/c"); 498 GURL url_c("http://google.com/c");
499 AddClientRedirect(url_b, url_c, true, &transition1, &transition2); 499 AddClientRedirect(url_b, url_c, true, &transition1, &transition2);
500 EXPECT_FALSE(transition1 & PageTransition::CHAIN_END); 500 EXPECT_FALSE(transition1 & PageTransition::CHAIN_END);
501 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END); 501 EXPECT_TRUE(transition2 & PageTransition::CHAIN_END);
502 } 502 }
503 503
504 } // namespace history 504 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/history/history_backend.cc ('k') | chrome/browser/history/history_marshaling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698