This source file includes following definitions.
- SetUpOnMainThread
- CreateBookmarkBubble
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/web_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const char kTestBookmarkURL[] = "http://www.google.com";
}
class BookmarkBubbleGtkBrowserTest : public InProcessBrowserTest {
public:
BookmarkBubbleGtkBrowserTest() {}
virtual void SetUpOnMainThread() OVERRIDE {
bookmark_utils::AddIfNotBookmarked(
BookmarkModelFactory::GetForProfile(browser()->profile()),
GURL(kTestBookmarkURL),
base::string16());
}
protected:
void CreateBookmarkBubble() {
BookmarkBubbleGtk::Show(GTK_WIDGET(browser()->window()->GetNativeWindow()),
browser()->profile(),
GURL(kTestBookmarkURL),
true);
}
private:
DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleGtkBrowserTest);
};
IN_PROC_BROWSER_TEST_F(BookmarkBubbleGtkBrowserTest, SyncPromoSignedIn) {
SigninManager* signin = SigninManagerFactory::GetForProfile(
browser()->profile());
signin->SetAuthenticatedUsername("fake_username");
CreateBookmarkBubble();
EXPECT_FALSE(BookmarkBubbleGtk::bookmark_bubble_->promo_);
}
IN_PROC_BROWSER_TEST_F(BookmarkBubbleGtkBrowserTest, SyncPromoNotSignedIn) {
CreateBookmarkBubble();
EXPECT_TRUE(BookmarkBubbleGtk::bookmark_bubble_->promo_);
}
IN_PROC_BROWSER_TEST_F(BookmarkBubbleGtkBrowserTest, SyncPromoLink) {
GURL initial_url =
browser()->tab_strip_model()->GetActiveWebContents()->GetVisibleURL();
CreateBookmarkBubble();
BookmarkBubbleGtk::bookmark_bubble_->OnSignInClicked(NULL, NULL);
EXPECT_NE(
initial_url,
browser()->tab_strip_model()->GetActiveWebContents()->GetVisibleURL());
}