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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
10 #include "chrome/browser/bookmarks/bookmark_utils.h" | 10 #include "chrome/browser/bookmarks/bookmark_utils.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 ASSERT_TRUE(original_complete_.get()); | 52 ASSERT_TRUE(original_complete_.get()); |
53 original_complete_->Wait(); | 53 original_complete_->Wait(); |
54 incognito_complete_->Wait(); | 54 incognito_complete_->Wait(); |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 | 58 |
59 virtual void Observe( | 59 virtual void Observe( |
60 int type, | 60 int type, |
61 const content::NotificationSource& source, | 61 const content::NotificationSource& source, |
62 const content::NotificationDetails& details) { | 62 const content::NotificationDetails& details) OVERRIDE { |
63 original_complete_.reset(new LazyBackgroundObserver(profile_)); | 63 original_complete_.reset(new LazyBackgroundObserver(profile_)); |
64 incognito_complete_.reset( | 64 incognito_complete_.reset( |
65 new LazyBackgroundObserver(profile_->GetOffTheRecordProfile())); | 65 new LazyBackgroundObserver(profile_->GetOffTheRecordProfile())); |
66 } | 66 } |
67 | 67 |
68 Profile* profile_; | 68 Profile* profile_; |
69 content::NotificationRegistrar registrar_; | 69 content::NotificationRegistrar registrar_; |
70 scoped_ptr<LazyBackgroundObserver> original_complete_; | 70 scoped_ptr<LazyBackgroundObserver> original_complete_; |
71 scoped_ptr<LazyBackgroundObserver> incognito_complete_; | 71 scoped_ptr<LazyBackgroundObserver> incognito_complete_; |
72 }; | 72 }; |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 class LazyBackgroundPageApiTest : public ExtensionApiTest { | 76 class LazyBackgroundPageApiTest : public ExtensionApiTest { |
77 public: | 77 public: |
78 void SetUpCommandLine(CommandLine* command_line) { | 78 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
79 ExtensionApiTest::SetUpCommandLine(command_line); | 79 ExtensionApiTest::SetUpCommandLine(command_line); |
80 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 80 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
81 // Set shorter delays to prevent test timeouts. | 81 // Set shorter delays to prevent test timeouts. |
82 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); | 82 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "1"); |
83 command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1"); | 83 command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "1"); |
84 } | 84 } |
85 | 85 |
86 // Loads the extension, which temporarily starts the lazy background page | 86 // Loads the extension, which temporarily starts the lazy background page |
87 // to dispatch the onInstalled event. We wait until it shuts down again. | 87 // to dispatch the onInstalled event. We wait until it shuts down again. |
88 const Extension* LoadExtensionAndWait(const std::string& test_name) { | 88 const Extension* LoadExtensionAndWait(const std::string& test_name) { |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 EXPECT_TRUE(event_page_ready.WaitUntilSatisfied()); | 441 EXPECT_TRUE(event_page_ready.WaitUntilSatisfied()); |
442 | 442 |
443 page_ready.Reply("go"); | 443 page_ready.Reply("go"); |
444 | 444 |
445 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 445 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
446 } | 446 } |
447 | 447 |
448 // TODO: background page with timer. | 448 // TODO: background page with timer. |
449 // TODO: background page that interacts with popup. | 449 // TODO: background page that interacts with popup. |
OLD | NEW |