OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include "chrome/test/base/browser_with_test_window_test.h" | 7 #include "chrome/test/base/browser_with_test_window_test.h" |
8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
9 #include "content/public/browser/site_instance.h" | 9 #include "content/public/browser/site_instance.h" |
10 | 10 |
| 11 typedef BrowserWithTestWindowTest BrowserTest; |
| 12 |
11 class TestingOffTheRecordDestructionProfile : public TestingProfile { | 13 class TestingOffTheRecordDestructionProfile : public TestingProfile { |
12 public: | 14 public: |
13 TestingOffTheRecordDestructionProfile() : destroyed_profile_(false) { | 15 TestingOffTheRecordDestructionProfile() : destroyed_profile_(false) { |
14 set_incognito(true); | 16 set_incognito(true); |
15 } | 17 } |
16 virtual void DestroyOffTheRecordProfile() OVERRIDE { | 18 virtual void DestroyOffTheRecordProfile() OVERRIDE { |
17 destroyed_profile_ = true; | 19 destroyed_profile_ = true; |
18 } | 20 } |
19 bool destroyed_profile_; | 21 bool destroyed_profile_; |
20 | 22 |
21 DISALLOW_COPY_AND_ASSIGN(TestingOffTheRecordDestructionProfile); | 23 DISALLOW_COPY_AND_ASSIGN(TestingOffTheRecordDestructionProfile); |
22 }; | 24 }; |
23 | 25 |
24 class BrowserTestOffTheRecord : public BrowserWithTestWindowTest { | 26 class BrowserTestOffTheRecord : public BrowserTest { |
25 public: | 27 public: |
26 BrowserTestOffTheRecord() : off_the_record_profile_(NULL) {} | 28 BrowserTestOffTheRecord() : off_the_record_profile_(NULL) {} |
27 | 29 |
28 protected: | 30 protected: |
29 virtual TestingProfile* CreateProfile() OVERRIDE { | 31 virtual TestingProfile* CreateProfile() OVERRIDE { |
30 if (off_the_record_profile_ == NULL) | 32 if (off_the_record_profile_ == NULL) |
31 off_the_record_profile_ = new TestingOffTheRecordDestructionProfile(); | 33 off_the_record_profile_ = new TestingOffTheRecordDestructionProfile(); |
32 return off_the_record_profile_; | 34 return off_the_record_profile_; |
33 } | 35 } |
34 TestingOffTheRecordDestructionProfile* off_the_record_profile_; | 36 TestingOffTheRecordDestructionProfile* off_the_record_profile_; |
35 | 37 |
36 DISALLOW_COPY_AND_ASSIGN(BrowserTestOffTheRecord); | 38 DISALLOW_COPY_AND_ASSIGN(BrowserTestOffTheRecord); |
37 }; | 39 }; |
38 | 40 |
39 // Various assertions around setting show state. | 41 // Various assertions around setting show state. |
40 TEST_F(BrowserWithTestWindowTest, GetSavedWindowShowState) { | 42 TEST_F(BrowserTest, GetSavedWindowShowState) { |
41 // Default show state is SHOW_STATE_DEFAULT. | 43 // Default show state is SHOW_STATE_DEFAULT. |
42 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, browser()->GetSavedWindowShowState()); | 44 EXPECT_EQ(ui::SHOW_STATE_DEFAULT, browser()->GetSavedWindowShowState()); |
43 | 45 |
44 // Explicitly specifying a state should stick though. | 46 // Explicitly specifying a state should stick though. |
45 browser()->set_show_state(ui::SHOW_STATE_MAXIMIZED); | 47 browser()->set_show_state(ui::SHOW_STATE_MAXIMIZED); |
46 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, browser()->GetSavedWindowShowState()); | 48 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, browser()->GetSavedWindowShowState()); |
47 browser()->set_show_state(ui::SHOW_STATE_NORMAL); | 49 browser()->set_show_state(ui::SHOW_STATE_NORMAL); |
48 EXPECT_EQ(ui::SHOW_STATE_NORMAL, browser()->GetSavedWindowShowState()); | 50 EXPECT_EQ(ui::SHOW_STATE_NORMAL, browser()->GetSavedWindowShowState()); |
49 browser()->set_show_state(ui::SHOW_STATE_MINIMIZED); | 51 browser()->set_show_state(ui::SHOW_STATE_MINIMIZED); |
50 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, browser()->GetSavedWindowShowState()); | 52 EXPECT_EQ(ui::SHOW_STATE_MINIMIZED, browser()->GetSavedWindowShowState()); |
(...skipping 25 matching lines...) Expand all Loading... |
76 | 78 |
77 // And asynchronicity kicked in properly. | 79 // And asynchronicity kicked in properly. |
78 MessageLoop::current()->RunAllPending(); | 80 MessageLoop::current()->RunAllPending(); |
79 EXPECT_FALSE(off_the_record_profile_->destroyed_profile_); | 81 EXPECT_FALSE(off_the_record_profile_->destroyed_profile_); |
80 | 82 |
81 // I meant, ALL the render process hosts... :-) | 83 // I meant, ALL the render process hosts... :-) |
82 render_process_host2.release()->Cleanup(); | 84 render_process_host2.release()->Cleanup(); |
83 MessageLoop::current()->RunAllPending(); | 85 MessageLoop::current()->RunAllPending(); |
84 EXPECT_TRUE(off_the_record_profile_->destroyed_profile_); | 86 EXPECT_TRUE(off_the_record_profile_->destroyed_profile_); |
85 } | 87 } |
OLD | NEW |