OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" |
10 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/test_extension_system.h" |
11 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 16 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
15 | 18 |
16 namespace { | 19 namespace { |
17 | 20 |
18 typedef BrowserWithTestWindowTest BookmarkSyncPromoControllerTest; | 21 class BookmarkSyncPromoControllerTest : public BrowserWithTestWindowTest { |
| 22 public: |
| 23 virtual void SetUp() { |
| 24 BrowserWithTestWindowTest::SetUp(); |
| 25 ASSERT_TRUE(profile()); |
| 26 // Adds TestExtensionSystem, since signin uses the gaia auth extension. |
| 27 static_cast<extensions::TestExtensionSystem*>( |
| 28 extensions::ExtensionSystem::Get(profile()))->CreateExtensionService( |
| 29 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 30 } |
| 31 }; |
19 | 32 |
20 TEST_F(BookmarkSyncPromoControllerTest, SignInLink) { | 33 TEST_F(BookmarkSyncPromoControllerTest, SignInLink) { |
21 int starting_tab_count = browser()->tab_strip_model()->count(); | 34 int starting_tab_count = browser()->tab_strip_model()->count(); |
22 | 35 |
23 base::scoped_nsobject<BookmarkSyncPromoController> syncPromo( | 36 base::scoped_nsobject<BookmarkSyncPromoController> syncPromo( |
24 [[BookmarkSyncPromoController alloc] initWithBrowser:browser()]); | 37 [[BookmarkSyncPromoController alloc] initWithBrowser:browser()]); |
25 | 38 |
26 // Simulate clicking the "Sign in" link. | 39 // Simulate clicking the "Sign in" link. |
27 [syncPromo textView:nil clickedOnLink:nil atIndex:0u]; | 40 [syncPromo textView:nil clickedOnLink:nil atIndex:0u]; |
28 | 41 |
29 // A new tab should have been opened. | 42 // A new tab should have been opened. |
30 int tab_count = browser()->tab_strip_model()->count(); | 43 int tab_count = browser()->tab_strip_model()->count(); |
31 EXPECT_EQ(starting_tab_count + 1, tab_count); | 44 EXPECT_EQ(starting_tab_count + 1, tab_count); |
32 } | 45 } |
33 | 46 |
34 } // namespace | 47 } // namespace |
OLD | NEW |