This source file includes following definitions.
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/test/integration/bookmarks_helper.h"
#include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "ui/base/layout.h"
using bookmarks_helper::AddFolder;
using bookmarks_helper::AddURL;
using bookmarks_helper::Create1xFaviconFromPNGFile;
using bookmarks_helper::GetBookmarkBarNode;
using bookmarks_helper::GetBookmarkModel;
using bookmarks_helper::GetOtherNode;
using bookmarks_helper::ModelMatchesVerifier;
using bookmarks_helper::Move;
using bookmarks_helper::Remove;
using bookmarks_helper::RemoveAll;
using bookmarks_helper::SetFavicon;
using bookmarks_helper::SetTitle;
using sync_integration_test_util::AwaitCommitActivityCompletion;
class SingleClientBookmarksSyncTest : public SyncTest {
public:
SingleClientBookmarksSyncTest() : SyncTest(SINGLE_CLIENT) {}
virtual ~SingleClientBookmarksSyncTest() {}
private:
DISALLOW_COPY_AND_ASSIGN(SingleClientBookmarksSyncTest);
};
IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest, Sanity) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
const BookmarkNode* top = AddFolder(0, GetOtherNode(0), 0, L"top");
const BookmarkNode* tier1_a = AddFolder(0, top, 0, L"tier1_a");
const BookmarkNode* tier1_b = AddFolder(0, top, 1, L"tier1_b");
const BookmarkNode* tier1_a_url0 = AddURL(
0, tier1_a, 0, L"tier1_a_url0", GURL("http://mail.google.com"));
const BookmarkNode* tier1_a_url1 = AddURL(
0, tier1_a, 1, L"tier1_a_url1", GURL("http://www.pandora.com"));
const BookmarkNode* tier1_a_url2 = AddURL(
0, tier1_a, 2, L"tier1_a_url2", GURL("http://www.facebook.com"));
const BookmarkNode* tier1_b_url0 = AddURL(
0, tier1_b, 0, L"tier1_b_url0", GURL("http://www.nhl.com"));
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
const BookmarkNode* bar = GetBookmarkBarNode(0);
const BookmarkNode* cnn = AddURL(0, bar, 0, L"CNN",
GURL("http://www.cnn.com"));
ASSERT_TRUE(cnn != NULL);
Move(0, tier1_a, bar, 1);
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
const BookmarkNode* porsche = AddURL(0, bar, 2, L"Porsche",
GURL("http://www.porsche.com"));
ASSERT_EQ(tier1_a, tier1_a_url2->parent());
ASSERT_EQ(tier1_a, tier1_a_url1->parent());
Move(0, tier1_a_url2, tier1_a, 0);
Move(0, tier1_a_url1, tier1_a, 2);
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
ASSERT_EQ(1, tier1_a_url0->parent()->GetIndexOf(tier1_a_url0));
Move(0, tier1_a_url0, bar, bar->child_count());
const BookmarkNode* boa = AddURL(0, bar, bar->child_count(),
L"Bank of America", GURL("https://www.bankofamerica.com"));
ASSERT_TRUE(boa != NULL);
Move(0, tier1_a_url0, top, top->child_count());
const BookmarkNode* bubble = AddURL(
0, bar, bar->child_count(), L"Seattle Bubble",
GURL("http://seattlebubble.com"));
ASSERT_TRUE(bubble != NULL);
const BookmarkNode* wired = AddURL(0, bar, 2, L"Wired News",
GURL("http://www.wired.com"));
const BookmarkNode* tier2_b = AddFolder(
0, tier1_b, 0, L"tier2_b");
Move(0, tier1_b_url0, tier2_b, 0);
Move(0, porsche, bar, 0);
SetTitle(0, wired, L"News Wired");
SetTitle(0, porsche, L"ICanHazPorsche?");
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
ASSERT_EQ(tier1_a_url0->id(), top->GetChild(top->child_count() - 1)->id());
Remove(0, top, top->child_count() - 1);
Move(0, wired, tier1_b, 0);
Move(0, porsche, bar, 3);
const BookmarkNode* tier3_b = AddFolder(0, tier2_b, 1, L"tier3_b");
const BookmarkNode* leafs = AddURL(
0, tier1_a, 0, L"Toronto Maple Leafs", GURL("http://mapleleafs.nhl.com"));
const BookmarkNode* wynn = AddURL(0, bar, 1, L"Wynn",
GURL("http://www.wynnlasvegas.com"));
Move(0, wynn, tier3_b, 0);
Move(0, leafs, tier3_b, 0);
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
}
IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest,
SetFaviconHiDPIDifferentCodec) {
std::vector<ui::ScaleFactor> supported_scale_factors;
supported_scale_factors.push_back(ui::SCALE_FACTOR_100P);
supported_scale_factors.push_back(ui::SCALE_FACTOR_200P);
ui::SetSupportedScaleFactors(supported_scale_factors);
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(ModelMatchesVerifier(0));
const GURL page_url("http://www.google.com");
const GURL icon_url("http://www.google.com/favicon.ico");
const BookmarkNode* bookmark = AddURL(0, L"title", page_url);
gfx::Image original_favicon = Create1xFaviconFromPNGFile(
"favicon_cocoa_png_codec.png");
ASSERT_FALSE(original_favicon.IsEmpty());
SetFavicon(0, bookmark, icon_url, original_favicon,
bookmarks_helper::FROM_SYNC);
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
scoped_refptr<base::RefCountedMemory> original_favicon_bytes =
original_favicon.As1xPNGBytes();
gfx::Image final_favicon = GetBookmarkModel(0)->GetFavicon(bookmark);
scoped_refptr<base::RefCountedMemory> final_favicon_bytes =
final_favicon.As1xPNGBytes();
EXPECT_TRUE(original_favicon_bytes.get());
EXPECT_TRUE(original_favicon_bytes->Equals(final_favicon_bytes));
}
IN_PROC_BROWSER_TEST_F(SingleClientBookmarksSyncTest,
BookmarkAllNodesRemovedEvent) {
ASSERT_TRUE(SetupClients()) << "SetupClients() failed.";
const BookmarkNode* folder0 = AddFolder(0, GetOtherNode(0), 0, L"folder0");
const BookmarkNode* tier1_a = AddFolder(0, folder0, 0, L"tier1_a");
ASSERT_TRUE(AddURL(0, folder0, 1, L"News", GURL("http://news.google.com")));
ASSERT_TRUE(AddURL(0, folder0, 2, L"Yahoo", GURL("http://www.yahoo.com")));
ASSERT_TRUE(AddURL(0, tier1_a, 0, L"Gmail", GURL("http://mail.google.com")));
ASSERT_TRUE(AddURL(0, tier1_a, 1, L"Google", GURL("http://www.google.com")));
ASSERT_TRUE(
AddURL(0, GetOtherNode(0), 1, L"CNN", GURL("http://www.cnn.com")));
ASSERT_TRUE(AddFolder(0, GetBookmarkBarNode(0), 0, L"empty_folder"));
const BookmarkNode* folder1 =
AddFolder(0, GetBookmarkBarNode(0), 1, L"folder1");
ASSERT_TRUE(AddURL(0, folder1, 0, L"Yahoo", GURL("http://www.yahoo.com")));
ASSERT_TRUE(
AddURL(0, GetBookmarkBarNode(0), 2, L"Gmail", GURL("http://gmail.com")));
ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
ASSERT_TRUE(ModelMatchesVerifier(0));
RemoveAll(0);
ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
EXPECT_EQ(0, GetOtherNode(0)->child_count());
EXPECT_EQ(0, GetBookmarkBarNode(0)->child_count());
ASSERT_TRUE(ModelMatchesVerifier(0));
}