Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2010 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 "base/command_line.h"
      6 #include "base/utf_string_conversions.h"
      7 #include "chrome/browser/bookmarks/bookmark_model.h"
      8 #include "chrome/browser/extensions/extension_apitest.h"
      9 #include "chrome/browser/extensions/extension_bookmark_manager_api.h"
     10 #include "chrome/browser/prefs/pref_service.h"
     11 #include "chrome/browser/profiles/profile.h"
     12 #include "chrome/browser/ui/browser.h"
     13 #include "chrome/common/chrome_switches.h"
     14 #include "chrome/common/pref_names.h"
     15 #include "chrome/test/ui_test_utils.h"
     16 
     17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManager) {
     18   CommandLine::ForCurrentProcess()->AppendSwitch(
     19       switches::kEnableExperimentalExtensionApis);
     20 
     21   ASSERT_TRUE(RunExtensionTest("bookmark_manager/standard")) << message_;
     22 }
     23 
     24 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BookmarkManagerEditDisabled) {
     25   CommandLine::ForCurrentProcess()->AppendSwitch(
     26       switches::kEnableExperimentalExtensionApis);
     27 
     28   Profile* profile = browser()->profile();
     29 
     30   // Provide some testing data here, since bookmark editing will be disabled
     31   // within the extension.
     32   BookmarkModel* model = profile->GetBookmarkModel();
     33   ui_test_utils::WaitForBookmarkModelToLoad(model);
     34   const BookmarkNode* bar = model->GetBookmarkBarNode();
     35   const BookmarkNode* folder = model->AddFolder(bar, 0, ASCIIToUTF16("Folder"));
     36   const BookmarkNode* node = model->AddURL(bar, 1, ASCIIToUTF16("AAA"),
     37                                            GURL("http://aaa.example.com"));
     38   node = model->AddURL(folder, 0, ASCIIToUTF16("BBB"),
     39                                   GURL("http://bbb.example.com"));
     40 
     41   profile->GetPrefs()->SetBoolean(prefs::kEditBookmarksEnabled, false);
     42 
     43   ASSERT_TRUE(RunExtensionTest("bookmark_manager/edit_disabled")) << message_;
     44 }
     45