Page Speed Optimization Libraries  1.3.25.1
net/instaweb/util/thread_system_test_base.h
Go to the documentation of this file.
00001 // Copyright 2011 Google Inc.
00016 
00017 #ifndef NET_INSTAWEB_UTIL_THREAD_SYSTEM_TEST_BASE_H_
00018 #define NET_INSTAWEB_UTIL_THREAD_SYSTEM_TEST_BASE_H_
00019 
00020 #include "net/instaweb/util/public/thread_system.h"
00021 
00022 #include "net/instaweb/util/public/basictypes.h"
00023 #include "net/instaweb/util/public/gtest.h"
00024 #include "net/instaweb/util/public/mock_message_handler.h"
00025 #include "net/instaweb/util/public/scoped_ptr.h"
00026 
00027 namespace net_instaweb {
00028 
00029 class ThreadSystemTestBase : public testing::Test {
00030  public:
00032   void set_ok_flag(bool ok) { ok_flag_ = ok; }
00033   bool ok_flag() const { return ok_flag_; }
00034 
00035   ThreadSystem* thread_system() const { return thread_system_.get(); }
00036 
00037  protected:
00039   explicit ThreadSystemTestBase(ThreadSystem* thread_system);
00040 
00042   void TestStartJoin();
00043 
00046   void TestSync();
00047 
00048  private:
00049   bool ok_flag_;
00050   scoped_ptr<ThreadSystem> thread_system_;
00051   MockMessageHandler handler_;
00052 
00053   DISALLOW_COPY_AND_ASSIGN(ThreadSystemTestBase);
00054 };
00055 
00058 template<typename ToTest>
00059 class ThreadSystemTestTemplate : public ThreadSystemTestBase {
00060  public:
00061   ThreadSystemTestTemplate() : ThreadSystemTestBase(new ToTest) {}
00062 };
00063 
00064 TYPED_TEST_CASE_P(ThreadSystemTestTemplate);
00065 
00066 TYPED_TEST_P(ThreadSystemTestTemplate, TestStartJoin) {
00067   ThreadSystemTestBase::TestStartJoin();
00068 }
00069 
00070 TYPED_TEST_P(ThreadSystemTestTemplate, TestSync) {
00071   ThreadSystemTestBase::TestSync();
00072 }
00073 
00074 REGISTER_TYPED_TEST_CASE_P(ThreadSystemTestTemplate, TestStartJoin, TestSync);
00075 
00076 }  
00077 
00078 #endif  ///< NET_INSTAWEB_UTIL_THREAD_SYSTEM_TEST_BASE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines