bookmark_manager_private_apitest.cc revision 5c02ac1a9c1b504631c0a3d2b6e737b5d738bae1
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.h" 6 7#include "base/command_line.h" 8#include "base/prefs/pref_service.h" 9#include "base/strings/utf_string_conversions.h" 10#include "chrome/browser/bookmarks/bookmark_model_factory.h" 11#include "chrome/browser/bookmarks/bookmark_test_helpers.h" 12#include "chrome/browser/extensions/extension_apitest.h" 13#include "chrome/browser/profiles/profile.h" 14#include "chrome/browser/ui/browser.h" 15#include "chrome/common/pref_names.h" 16#include "components/bookmarks/core/browser/bookmark_model.h" 17#include "components/user_prefs/user_prefs.h" 18 19// Times out on win syzyasan, http://crbug.com/166026 20#if defined(SYZYASAN) 21#define MAYBE_BookmarkManager DISABLED_BookmarkManager 22#else 23#define MAYBE_BookmarkManager BookmarkManager 24#endif 25IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_BookmarkManager) { 26 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/standard")) 27 << message_; 28} 29 30IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) { 31 Profile* profile = browser()->profile(); 32 33 // Provide some testing data here, since bookmark editing will be disabled 34 // within the extension. 35 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); 36 test::WaitForBookmarkModelToLoad(model); 37 const BookmarkNode* bar = model->bookmark_bar_node(); 38 const BookmarkNode* folder = 39 model->AddFolder(bar, 0, base::ASCIIToUTF16("Folder")); 40 model->AddURL(bar, 1, base::ASCIIToUTF16("AAA"), 41 GURL("http://aaa.example.com")); 42 model->AddURL(folder, 0, base::ASCIIToUTF16("BBB"), 43 GURL("http://bbb.example.com")); 44 45 PrefService* prefs = user_prefs::UserPrefs::Get(profile); 46 prefs->SetBoolean(prefs::kEditBookmarksEnabled, false); 47 48 ASSERT_TRUE(RunComponentExtensionTest("bookmark_manager/edit_disabled")) 49 << message_; 50} 51